//Porzuccie wszelka nadzieje wy, ktorzy tu wstepujecie. ("Abandon all hope, ye who enter here.")

class GuncasterWeapon : Weapon
{
	Default
	{
		Weapon.AmmoUse2 0;
		Weapon.Kickback 100;
        Inventory.PickupSound "Guncaster/Laugh1";
		+WEAPON.ALT_USES_BOTH
        +WEAPON.NOALERT
	}
	
	//Golden quote you didn't ask for: "I'll sacrifice my first-born just so Satan
	//will come over this plane and impregnate your asshole with self-loathing violence."
	
	int WeapAction; //Lock deselect when the weapon functions are currently in use.
	int WeapSwitch; //Lock weapon functions if its currently being switched.
	
	int LeftHand; 	//Lock weapon/right hand for melee/two-handed weapon if your left hand is occupied. (See for instance: Longhorn's Strat fire.)
	int WeaponInUse; //Same as LeftHand, except here it implies when the weapon or melee punching occurs, it should lock your casting.
	int HandCast;	//Extra animation for hand going off the weapon/down in melee before casting.
	int StratCast;	//To determine if you have Stratocaster mode active, so it can play its own hand animation before going for cast.

    double GMod;    //When Gunzerk Modifier is active, it should decrease recoil by half.
	
	int Loopler;    //Used for looping things. (For instance, Gunsmoke/Longhorn puffs.)
	int KickDir;	//Determine the roundhouse direction.
	int LoopKick;   //Loops animations on kick overlay.
	int LoopKickDir; //Determines frame direction on the the kick overlay.
	
	int LoopRight;  //--||-- on right overlay.
	int LoopZoom;   //--||-- on zoom overlay.
	int LoopRecoil;  //--||-- on recoil overlay.

	int LoopLeft;  //--||-- on left overlay.
	int LoopZoom2;   //--||-- on left zoom overlay.
	int LoopRecoil2;  //--||-- on left recoil overlay.
	
	float Bump; 	//A thing to shake Deadmaker's quick-punch upon impact.
	int GracePeriod;	//Deadmaker's sprint activation time.
	
	Gc_Prism Prism;	// The prism lazer spinning and spawning handling
	
	//Do you have any idea how much alcohol went into making this?
	
	//This one's for built-in sound handle for pickups.
	override void PostBeginPlay()
	{
		if(gameinfo.gametype == Game_HERETIC || gameinfo.gametype == Game_HEXEN)
		{
			PickupSound = "Guncaster/Laugh1";
		}
		else
		{
			PickupSound = "misc/w_pkup";
		}
		
		Super.PostBeginPlay();
		Return;
	}
	
	// A BFGSpray alternative that A. fires from your weapon, and B. sets the tracer of the spawned spray to the hit target.
	// Yes, I [Zhs2] am aware that firing it from the weapon won't exactly set an obituary.
	
	action void A_TracerSpray(class<Actor> spraytype = "BFGExtra", int numrays = 40, int damagecnt = 15, double ang = 90, double distance = 16*64, double vrange = 32, int defdamage = 0, int flags = 0)
	{
		int damage;
		FTranslatedLineTarget t;

		// validate parameters
		if (spraytype == null) spraytype = "BFGExtra";
		if (numrays <= 0) numrays = 40;
		if (damagecnt <= 0) damagecnt = 15;
		if (ang == 0) ang = 90.;
		if (distance <= 0) distance = 16 * 64;
		if (vrange == 0) vrange = 32.;

		// offset angles from its attack ang
		for (int i = 0; i < numrays; i++)
		{
			double an = angle - ang / 2 + ang / numrays*i;
			
			// Fires from self.
			AimLineAttack(an, distance, t, vrange);

			if (t.linetarget != null)
			{
				Actor spray = Spawn(spraytype, t.linetarget.pos + (0, 0, t.linetarget.Height / 4), ALLOW_REPLACE);

				int dmgFlags = 0;
				Name dmgType = 'BFGSplash';

				if (spray != null)
				{
					// No reliance on PUFFGETSOWNER - anything fired by the player should be owned by the player.
					spray.target = self;
					// The most important change. The linetarget is the spray's tracer, for extra effects.
					spray.tracer = t.linetarget;
					if ((spray.bMThruSpecies && GetSpecies() == t.linetarget.GetSpecies()) || 
						(!(flags & BFGF_HURTSOURCE) && self == t.linetarget)) // [XA] Don't hit oneself unless we say so.
					{
						spray.Destroy(); // [MC] Remove it because technically, the spray isn't trying to "hit" them.
						continue;
					}
					if (spray.bFoilInvul) dmgFlags |= DMG_FOILINVUL;
					if (spray.bFoilBuddha) dmgFlags |= DMG_FOILBUDDHA;
					dmgType = spray.DamageType;
				}

				if (defdamage == 0)
				{
					damage = 0;
					for (int j = 0; j < damagecnt; ++j)
						damage += Random[BFGSpray](1, 8);
				}
				else
				{
					// if this is used, damagecnt will be ignored
					damage = defdamage;
				}

				int newdam = t.linetarget.DamageMobj(self, target, damage, dmgType, dmgFlags|DMG_USEANGLE, t.angleFromSource);
				t.TraceBleed(newdam > 0 ? newdam : damage, self);
			}
		}
	}
	
	States
	{
    Ready:
        TNT1 A 0 {	//Mmmmmm yissss undefined operators for teh winz, yissss~
			invoker.WeapAction = 0;
			invoker.WeapSwitch = 0;
			
			invoker.WeaponInUse = 0;
			invoker.LeftHand = 0;
			
			invoker.HandCast = 0;
			invoker.StratCast = 0;
			
			invoker.Gmod = 1.0;
	
			invoker.Loopler = 0;
			invoker.LoopKick = 0;
			invoker.LoopKickDir = 0;
	
			invoker.LoopRight = 0;
			invoker.LoopZoom = 0;
			invoker.LoopRecoil = 0;

			invoker.LoopLeft = 0;
			invoker.LoopZoom2 = 0;
			invoker.LoopRecoil2 = 0;
			
			Return ResolveState("ReadyLoop");
		}
		Goto ReadyLoop;
		
    ReadyLoop:
		TNT1 A 0 A_JumpIf(invoker.WeapAction > 0 || invoker.LeftHand || invoker.WeaponInUse, 2); //If the gun actions are involved, cancel out ability for weapon change.
        TNT1 A 1 A_WeaponReady;
        Loop;
		TNT1 A 1 A_WeaponReady(WRF_NOSWITCH); 
		Loop;
		
    Fire: //Arbitrary states so things will load correctly.
        TNT1 A 0;
        Goto ReadyLoop;
	AltFire:
		TNT1 A 0;
		Goto ReadyLoop;
		
	RightActive:
		TNT1 A 0 A_Jump(256,"RightActive");
		Stop;
	LeftActive:
		TNT1 A 0 A_Jump(256,"LeftActive");
		Stop;
		
	Select:
		TNT1 A 0 {
			A_TakeInventory("GCLedgeGrabbed");
			SetPlayerProperty(0,0,2);
			A_ZoomFactor(1.0);
			//ACS_NamedExecuteAlways("KD Laser Pointer Tic", 0); // Pillow: YOU CALL THIS ON ENTER YOU FUCKING NUMBNUT~
			invoker.WeapAction = 0;			//Wipe any weapon action tokens if there were left there while selecting.
			invoker.WeaponInUse = 0;
			invoker.LeftHand = 0;
			
			invoker.HandCast = 0;
			invoker.StratCast = 0;
			
			invoker.WeapSwitch = 1;					//Weapon is switching, prevent from using things.
			A_Overlay(-10,"GrabThing");				//Check for barrels/pods.
			A_Overlay(-11,"LedgeGrab");				//What says on the tin.
			A_Overlay(-9,"KickActive");				//The kick loop. The kick stuff will be handled in base weapon later.
			A_Overlay(-3,"RightActive");			//Right side active. The right side is on the minus, as the left side overlaps the right.
			A_Overlay(3,"LeftActive");				//Left side active.
			A_Overlay(100,"SprintHandle");			//Deadmaker's sprint.
			
			//Reserved overlays.
			//A_Overlay(9,"CrowLaunch");
			//A_Overlay(6,"LeftStratShadowHand");
			//A_Overlay(-2,"RightStratShadowHand");
			//A_Overlay(-4,"RightFireRecoil")
			//A_Overlay(-5,"RightFireZoom");
			//A_Overlay(4,"LeftFireRecoil");
			//A_Overlay(5,"LeftFireZoom");
			
			Return ResolveState("SelectStuff");
		}
		Goto SelectStuff;
		
	GrabThing:
		TNT1 A 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & (BT_USE) &&
						  ((A_JumpIfTargetInLOS("Null",0,0,164) && CountInv("PowerDeadmaker")) || A_JumpIfTargetInLOS("Null",0,0,100)) &&
						  !CountInv("MenuWheelActive") &&
						 (AimTarget() is "PopBarrel" ||
						  AimTarget() is "PopBarrel2" ||
						  AimTarget() is "PodZwei"),"Grabbag");
		Loop;
	Grabbag:
		TNT1 A 0 {
			if(Invoker.Prism) {
				Invoker.Prism.End();
			}
			
			SetPlayerProperty(0,1,2);
			Guncaster(self).GC_SetPreviousWeapon();
			A_GiveInventory("ThrowObjectWeapon",1);
			A_SelectWeapon("ThrowObjectWeapon");
		}
		Stop;
		
	LedgeGrab:
		TNT1 A 1 A_JumpIf(CountInv("GCLedgeGrabbed"),"OwTheEdge");
		Loop;
	OwTheEdge:
		TNT1 A 0 {
			if(Invoker.Prism) {
				Invoker.Prism.End();
			}
			
			SetPlayerProperty(0,1,2);
			invoker.WeapAction = 0;
			invoker.LeftHand = 0;
			invoker.WeaponInUse = 0;
			Guncaster(self).GC_SetPreviousWeapon();
			A_GiveInventory("LedgeGrabWeapon",1);
			A_SelectWeapon("LedgeGrabWeapon");
		}
		Stop;
	
	//Deadmaker sprint. Ravioli Ravioli Pizza fucking Pasta code. I should fix this. Somehow. Maybe in another life.
	SprintHandle:
		TNT1 A 1 {
			if(!CountInv("PowerDeadmaker")) { Return ResolveState(Null); }
			if(Guncaster(self).ChargeCooldown) { Guncaster(self).ChargeCooldown--; Return ResolveState(Null); }
			
			//if(GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM) {
				if(CountInv("DeadmakerCharger") /*&& GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM*/ && GetPlayerInput(INPUT_BUTTONS) & BT_FORWARD) { Return ResolveState("SprintMain"); }
				if(Invoker.GracePeriod && (GetPlayerInput(INPUT_BUTTONS) & BT_FORWARD) && !(GetPlayerInput(INPUT_OLDBUTTONS) & BT_FORWARD)) {
					Return ResolveState("SprintMain");
				}
				if((GetPlayerInput(INPUT_BUTTONS) & BT_FORWARD) && !(GetPlayerInput(INPUT_OLDBUTTONS) & BT_FORWARD)) {
					Invoker.GracePeriod = GetCvar("GC_SprintTimer");
				}
			//}
			A_TakeInventory("DeadmakerCharger",1);
			//A_LogInt(Guncaster(self).ChargeFuel);
			if(Invoker.GracePeriod) { Invoker.GracePeriod--; }
			Return ResolveState(Null);
		}
		Loop;
	SprintMain:
		TNT1 A 1 {
			if(!Guncaster(self).ChargeCooldown && Guncaster(self).ChargeFuel > 72 && !(GetPlayerInput(INPUT_BUTTONS) & BT_CROUCH) && 
			  /* GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM &&*/ GetPlayerInput(INPUT_BUTTONS) & BT_FORWARD) {
				Invoker.GracePeriod = 0;
				if(Guncaster(self).ChargeFuel <= 75) {
					A_TakeInventory("DeadmakerCharger",1);
					Guncaster(self).ChargeCooldown = 50;
					Return ResolveState(Null);
				}
				if(Player.OnGround && !CountInv("DeadmakerCharger")) {
					A_PlaySound("Stomp/Use",7);
					A_GiveInventory("DeadmakerCharger",1);
				}
				Return A_Jump(256,1);
			} else {
				A_TakeInventory("DeadmakerCharger",1);
			}
			Return ResolveState(Null);
		}
		Goto SprintHandle;
		TNT1 A 1 {
			if(Player.OnGround) {
				Guncaster(self).ChargeFuel = Guncaster(self).ChargeFuel - random(1,2);
				A_Recoil(-3.0);
			} else if(CountInv("DeadmakerCharger")) {
				Guncaster(self).ChargeFuel = Guncaster(self).ChargeFuel - 1;
				A_Recoil(-2.0);
			}
		}
		Goto SprintHandle;
		
	//Deadmaker quick punch.
	DeadPunchEnter:
		TNT1 A 0;
		TNT1 A 0 A_Jump(256,"DeadPunchStart");
	DeadPunchStart:
		TNT1 A 0 A_OverlayFlags(OverlayID(),PSPF_MIRROR|PSPF_FLIP,1);
		DPNC A 0 A_JumpIf(CountInv("PowerSuitDraugh"),2);
		NPNC A 0;
		"####" C 1 A_OverlayOffset(OverlayID(),249,150);
		"####" C 1 A_OverlayOffset(OverlayID(),220,126,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),178,89,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),162,80,WOF_INTERPOLATE);
		"####" B 1 A_OverlayOffset(OverlayID(),149,75,WOF_INTERPOLATE);
		"####" B 1 A_OverlayOffset(OverlayID(),138,71,WOF_INTERPOLATE);
	DeadPunchCharging:
		"####" B 1 {
			A_OverlayOffset(OverlayID(),134+frandom(0.50,-0.50),69+frandom(0.50,-0.50),WOF_INTERPOLATE);
			A_GiveInventory("DeadmakerBracing",1);
		}
		"####" B 0 A_JumpIf(Health >= 0 && GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM, "DeadPunchCharging");
		"####" C 1 A_OverlayOffset(OverlayID(),178,59,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),220,96,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),249,120,WOF_INTERPOLATE);
		TNT1 A 2;
		TNT1 A 0 A_Jump(256,"DeadPunchIncoming");
	DeadPunchIncoming:
		TNT1 A 0 { invoker.LeftHand = 1; }
		DPNC A 0 A_JumpIf(CountInv("PowerSuitDraugh"),2);
		NPNC A 0;
		"####" C 0 A_PlaySound("Deadmaker/Woosh",1);
		TNT1 A 4;
		DPNC A 0 A_JumpIf(CountInv("PowerSuitDraugh"),2);
		NPNC A 0;
		"####" C 1 A_OverlayOffset(OverlayID(),249,120);
		"####" C 1 A_OverlayOffset(OverlayID(),220,96,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),178,59,WOF_INTERPOLATE);
		"####" B 1 {
			A_ChangeVelocity (Cos(Pitch) * 12, 0, Sin(Pitch) * -12, CVF_RELATIVE);
			A_OverlayOffset(OverlayID(),134,39,WOF_INTERPOLATE);
			if(!CountInv("PowerMidasMode")) { A_CustomPunch(500+randompick(0,25,50,75,100),1,CPF_NOTURN,"DeadmakerPunchPuff",275,0.05); }
			else							{ A_CustomPunch(500+randompick(0,25,50,75,100),1,CPF_NOTURN,"DeadmakerMidasPunchPuff",275,0.05); }
			//A_CustomPunch(0,1,CPF_NOTURN,"DeadmakerCheckPuff",265);
		}
		"####" B 0 A_JumpIf(CountInv("PunchConnected"),1);
		Goto DeadPunchWhiff;
	DeadPunchHit:
		"####" B 0 {
			Invoker.Bump = 15.0;
			A_TakeInventory("PunchConnected",1);
			if(CountInv("DeadmakerCharger")) {
				Guncaster(self).ChargeCooldown = 15;
				Guncaster(self).ChargeFuel = Guncaster(self).ChargeFuel - 75;
				A_TakeInventory("DeadmakerCharger",1);
			}
			//if(!CountInv("PowerMidasMode")) { A_CustomPunch(500+randompick(0,25,50,75,100),1,CPF_NOTURN,"DeadmakerPunchPuff",275,0.05); }
			//else							{ A_CustomPunch(500+randompick(0,25,50,75,100),1,CPF_NOTURN,"DeadmakerMidasPunchPuff",275,0.05); }
		}
		"####" BBBBBBBBBBBBBBB 1 {
				Invoker.Bump = Invoker.Bump - 1.0;
				A_OverlayOffset(OverlayID(),134+(Invoker.Bump*random(-1,1)),39+(Invoker.Bump*random(-1,1)),WOF_INTERPOLATE);
		}
		"####" B 1 A_OverlayOffset(OverlayID(),138,41,WOF_INTERPOLATE);
		"####" B 1 A_OverlayOffset(OverlayID(),149,45,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),162,50,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),178,59,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),220,96,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),249,120,WOF_INTERPOLATE);
		TNT1 A 12 A_OverlayFlags(OverlayID(),PSPF_MIRROR|PSPF_FLIP,0);
		TNT1 A 0 A_JumpIf(Health >= 0 && GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM, "DeadPunchStart");
		TNT1 A 0 A_Jump(256,"DeadPunchExit");
		Goto DeadPunchExit;
	DeadPunchWhiff:
		"####" B 1 A_OverlayOffset(OverlayID(),88,43,WOF_INTERPOLATE);
		"####" B 1 A_OverlayOffset(OverlayID(),56,54,WOF_INTERPOLATE);
		"####" A 1 A_OverlayOffset(OverlayID(),29,69,WOF_INTERPOLATE);
		"####" A 1 A_OverlayOffset(OverlayID(),57,89,WOF_INTERPOLATE);
		"####" A 1 A_OverlayOffset(OverlayID(),81,115,WOF_INTERPOLATE);
		"####" A 1 A_OverlayOffset(OverlayID(),112,133,WOF_INTERPOLATE);
		TNT1 A 12 A_OverlayFlags(OverlayID(),PSPF_MIRROR|PSPF_FLIP,0);
		TNT1 A 0 A_JumpIf(Health >= 0 && GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM, "DeadPunchStart");
		TNT1 A 0 A_Jump(256,"DeadPunchExit");
		Goto DeadPunchExit;
	DeadPunchExit:
		TNT1 A 0 { invoker.LeftHand = 0; }
		TNT1 A 0 A_Jump(256,"LeftActive");
		Goto LeftActive;
		
	SelectStuff:
		TNT1 A 0;
		Goto SelectLoop;
	SelectLoop:
        TNT1 A 1 A_Raise(12);
        Loop;
    Deselect:
		TNT1 A 0 {
			if(Invoker.Prism) {
				Invoker.Prism.End();
			}
			
			A_TakeInventory("SheepActive",1);
			SetPlayerProperty(0,0,PROP_FROZEN);
			A_ZoomFactor(1.0);
			//bNogravity = 0;
			invoker.WeapSwitch = 1;			//Weapon is switching, prevent from using things.
			Return ResolveState("DeselectStuff");
		}
		
	DeselectStuff:
		TNT1 A 0;
		Goto SelectLoop;
    DeselectLoop:
        TNT1 A 1 A_Lower(12);
        Loop;
		
	DeadLowered:
		TNT1 A 0 {
			A_StopSound(0);
			A_StopSound(5);
			A_StopSound(6);
			A_ZoomFactor(1.0);
		}
		TNT1 A -1;
		Stop;
	
	//Kick stuff.
    KickActive:
        TNT1 A 1 {
			if(GetCvar("GC_Trogdor") && !CountInv("DergfistSupremeSelected")) { Return ResolveState(Null); } //Cancel out kicking if you TROGDOOOOOR~
			if((CountInv("DergfistSelected") || CountInv("DergfistSupremeSelected")) && !invoker.WeapSwitch && (GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM) && (GetPlayerInput(INPUT_BUTTONS) & (BT_LEFT|BT_MOVELEFT)))
			{
				invoker.KickDir = -1;
				Return ResolveState("RoundhouseFire");
			}
			if((CountInv("DergfistSelected") || CountInv("DergfistSupremeSelected")) && !invoker.WeapSwitch && (GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM) && (GetPlayerInput(INPUT_BUTTONS) & (BT_RIGHT|BT_MOVERIGHT)))
			{
				invoker.KickDir = 1;
				Return ResolveState("RoundhouseFire");
			}
			if(/*(CountInv("DergfistSelected") || CountInv("DergfistSupremeSelected")) &&*/ !CountInv("PowerFootstompCooldown") && player.OnGround && !invoker.WeapSwitch && (GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM) && (GetPlayerInput(INPUT_BUTTONS) & (BT_CROUCH)))
			{
				Return ResolveState("StomperFire");
			}
			//Didn't figure out implementation for it, and I am not happy with results, anyway.
			/*if(CountInv("DergfistSelected") || CountInv("DergfistSupremeSelected")) && !CountInv("PowerFootstompCooldown") && A_CheckFloor("Null") && !invoker.WeapSwitch && (GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM) && (GetPlayerInput(INPUT_BUTTONS) & (BT_BACK)))
			{
				Return ResolveState("GenocideCutter");
			}*/
			if(!invoker.WeapSwitch && GetPlayerInput(INPUT_BUTTONS) & BT_ZOOM)
			{
				Return ResolveState("KickFire");
			}
			Return ResolveState(Null);
		}
        Loop;

	KickFire:
        TNT1 A 0 {
			invoker.WeapAction++;
			A_OverlayFlags(-9,PSPF_FLIP|PSPF_MIRROR,0); //missus roundhouse tends to flip things.
			//Occasional kick grunt.
            if (random(1,4) == 1)
            {
                A_PlaySound("Guncaster/Kick",2);
            }
           
            //Kick sound.
			if(CountInv("PowerDeadmaker"))	//You have deadmaker?
            {
                A_AlertMonsters(256);
                A_PlaySound("Deadmaker/Woosh",1);
                A_GiveInventory("DeadSuckerKick");
            }
            else if(CountInv("PowerSuitToken"))	//You have powersuit?
            {
                A_AlertMonsters(256);
                A_PlaySound("Bishop/Kick",1,0.9);
                If(CountInv("PowerBerserkDamage"))
                {
                    A_GiveInventory("PowerSuckerKick");
                }
            }
            else if(CountInv("PowerBerserkDamage")) //You have berserk?
            {
                A_GiveInventory("SuckerKick");
                A_PlaySound("SuperKick/Init",1,0.9);
            }
            else //Regular kick it is then.
            {
                A_PlaySound("Kick/Init",1,0.7);
            }
           
            if (CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect") && !CountInv("PowerSuitToken"))
            {
                A_PlaySound("Draughcaster/Move",5,0.6);
            }
            else if (!CountInv("PowerSuitToken") && !CountInv("PowerDeadmaker"))
            {
                A_PlaySound("Kick/Extra",5,0.7);
            }
           
            if (A_CheckFloor("Null") && GetPlayerInput(INPUT_BUTTONS) & BT_FORWARD) //Check if you are standing on any floor.
            {
				A_ChangeVelocity(0,0,-8.0,CVF_RELATIVE);
				if(CountInv("PowerSuitToken"))
				{
					A_PlaySound("Bishop/Wings",6);
					A_SpawnItemEx("Rocketkick_Emitter",0,0,0,0,0,0,0,SXF_ORIGINATOR|SXF_SETMASTER);
					A_ChangeVelocity (Cos(Pitch) * 64, 0, 0, 1);
				}
				else
				{
					A_PlaySound("Move/Slide",6);
					A_ChangeVelocity (Cos(Pitch) * 32, 0, 0, CVF_RELATIVE);
				}
            }
            else //If you are mid-air, give yourself a small, directional thrust.
            {
                A_ChangeVelocity (Cos(Pitch) * 12, 0, Sin(Pitch) * -12, CVF_RELATIVE);
            }
			
			invoker.LoopKick = 0;
			invoker.LoopKickDir = 1;
        }
		goto KickZoom;
    KickZoom:
		KDCK A 0 A_JumpIf(CountInv("PowerDeadmaker") && CountInv("PowerSuitDraugh"),7);
		KNCK A 0 A_JumpIf(CountInv("PowerDeadmaker"),6);
		KCCK A 0 A_JumpIf(CountInv("PowerSuitToken"),5);
		KUCK A 0 A_JumpIf(CountInv("PowerSuitProtect"),4);
		KYCK A 0 A_JumpIf(CountInv("PowerSuitDraugh"),3);
		KMCK A 0 A_JumpIf(CountInv("PowerMidasMode"),2);
		KICK A 0;
		"####" AAAAA 1 {
			static const double x[] = {-31.0, -21.0, -17.0, -8.0, 4.0};	//Kick offset.
			static const double y[] = {81.0, 87.0, 54.0, 43.0, 34.0};
			static const double zoom[] = {1.0, 0.99, 0.98, 0.97, 0.96, 0.95};
			
			int q = invoker.LoopKick;
			int zq = q + (invoker.LoopKickDir > 0 ? 1 : 0);
			invoker.LoopKick += invoker.LoopKickDir;
			int flags = (q == 0) ? 0 : WOF_INTERPOLATE;
			
			A_OverlayOffset(-9, x[q], y[q], flags);
			if (GetCVar("GC_ZoomRecoil")) A_ZoomFactor(zoom[zq]);
		}
		TNT1 A 0 {
			if (invoker.LoopKickDir > 0) {
				invoker.LoopKick = 0;
				return ResolveState("KickAttack");
			} else return ResolveState("KickFinish");
		}
    KickAttack:
		KDCK B 0 A_JumpIf(CountInv("PowerDeadmaker") && CountInv("PowerSuitDraugh"),7);
		KNCK B 0 A_JumpIf(CountInv("PowerDeadmaker"),6);
		KCCK B 0 A_JumpIf(CountInv("PowerSuitToken"),5);
		KUCK B 0 A_JumpIf(CountInv("PowerSuitProtect"),4);
		KYCK B 0 A_JumpIf(CountInv("PowerSuitDraugh"),3);
		KMCK B 0 A_JumpIf(CountInv("PowerMidasMode"),2);
		KICK B 0;
		"####" BBBB 1 {
			static const double x[] = {20.0, 25.0, 30.0, 32.0};	//Kick offset.
			static const double y[] = {33.0, 28.0, 24.0, 23.0};
			int q = invoker.LoopKick;
			invoker.LoopKick += invoker.LoopKickDir;
			A_OverlayOffset(-9, x[q], y[q], WOF_INTERPOLATE);
            A_SetPitch(pitch - 0.75 * GetCvar("GC_WeaponRecoil") * invoker.LoopKickDir, SPF_INTERPOLATE);
            A_SetAngle(angle - 0.75 * GetCvar("GC_WeaponRecoil") * invoker.LoopKickDir, SPF_INTERPOLATE);
			
            if (!CountInv("KickethThyHappend")) {
                bool powerSuit = CountInv("PowerSuitToken");
                bool kicking = CountInv("PowerSuitDraugh") && !powerSuit && !CountInv("PowerSuitProtect");
				String deadmakerName = String.Format(
					"%sDeadmakerKickProjectile",
					(CountInv("PowerMidasMode") ? "Midas" : "")
				);
                String projectileName = String.Format(
                    "%s%s%s%sProjectile",
                    (CountInv("PowerBerserkDamage") ? "Super" : ""),
                    (powerSuit ? "Power" : ""),
                    (CountInv("PowerMidasMode") ? "Midas" : ""),
                    (kicking ? "Foot" : "Kick")
                );
				if (CountInv("PowerSuitToken") && invoker.LoopKick == 4) {
					A_SpawnItemEx("KickDustSpawner",0,0,0,0,0,0,0,SXF_CLIENTSIDE);
				}
				
				if(CountInv("PowerDeadmaker")) {
					A_FireProjectile(deadmakerName, 0, 0);
				} else {
					A_FireProjectile(projectileName, 0, 0);
				}
            }
		}
		TNT1 A 0 {
			if (invoker.LoopKickDir > 0) {
				invoker.LoopKickDir = -1;
				invoker.LoopKick = 3;
				return ResolveState("KickAttack");
			} else {
				invoker.LoopKick = 4;
				return ResolveState("KickZoom");
			}
		}
		Goto KickFinish;
    KickFinish:
        TNT1 A 10 {
			A_TakeInventory("KickethThyHappend");
			invoker.WeapAction--;
		}
        Goto KickActive;
		
	RoundhouseFire:
		KDCK D 0 A_JumpIf(CountInv("PowerDeadmaker") && CountInv("PowerSuitDraugh"),7);
		KNCK D 0 A_JumpIfInventory("PowerDeadmaker",1,6);
		KCCK D 0 A_JumpIfInventory("PowerSuitToken",1,5);
		KUCK D 0 A_JumpIfInventory("PowerSuitProtect",1,4);
		KYCK D 0 A_JumpIfInventory("PowerSuitDraugh",1,3);
		KMCK D 0 A_JumpIfInventory("PowerMidasMode",1,2);
		KICK D 0;
		"####" "#" 0 {
			invoker.WeapAction++;
			if(invoker.KickDir > 0){ A_OverlayFlags(-9,PSPF_FLIP|PSPF_MIRROR,1); }
			else		  		   { A_OverlayFlags(-9,PSPF_FLIP|PSPF_MIRROR,0); }
			SetPlayerProperty(0,1,PROP_FROZEN);
			if(CountInv("PowerDeadmaker"))
            {
                A_AlertMonsters(256);
                A_PlaySound("Deadmaker/Woosh",1);
                A_GiveInventory("DeadSuckerKick");
            }
			Else if(CountInv("PowerSuitToken"))
			{
				A_AlertMonsters(256);
				A_PlaySound("Bishop/Kick",1,0.9);
				If(CountInv("PowerBerserkDamage"))
				{
					A_GiveInventory("PowerSuckerKick");
				}
			}
			Else If(CountInv("PowerBerserkDamage"))
			{
				A_GiveInventory("SuckerKick");
				A_PlaySound("SuperKick/Init",1,0.9);
			}
			Else
			{
				A_PlaySound("Kick/Init",1,0.7);
			}
			
			if((!CountInv("PowerSuitToken") && !CountInv("PowerSuitProtect")) && CountInv("PowerSuitDraugh"))
			{
				A_PlaySound("Draughcaster/Move",5,0.6);
			}
			else if(!CountInv("PowerSuitToken"))
			{
				A_PlaySound("Kick/Extra",5,0.7);
			}
			
			if(random(1,4) == 1) { A_PlaySound("Guncaster/Kick",2); }
		}
		"####" "#" 1 {
			A_OverlayOffset(-9,305,107);
			A_SetAngle(angle-45.0 * invoker.KickDir, SPF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.99); }
		}
		"####" "#" 1 {
			A_OverlayOffset(-9,250,87,WOF_INTERPOLATE);
			A_SetAngle(angle-45.0 * invoker.KickDir, SPF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.98); }
		}
		"####" "#" 1 {
			A_OverlayOffset(-9,191,74,WOF_INTERPOLATE);
			A_SetAngle(angle-45.0 * invoker.KickDir, SPF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.97); }
		}
		"####" "#" 1 {
			A_OverlayOffset(-9,130,67,WOF_INTERPOLATE);
			A_SetAngle(angle-45.0 * invoker.KickDir, SPF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); }
		}
		"####" "####" 1 {
			A_SetAngle(angle-45.0 * invoker.KickDir, SPF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.95); }
		}
		"####" "#" 0 {
			//Oh Jesus H. Christ, this is gonna be something else...
			
			//Do we have Deadmaker?
			If(CountInv("PowerDeadmaker"))
			{
			//Do we have midas?
				If(CountInv("PowerMidasMode"))
				{
					if(invoker.KickDir > 0) { A_FireProjectile("MidasDeadmakerKickProjectileRight",0,0); }
					else					{ A_FireProjectile("MidasDeadmakerKickProjectileLeft",0,0); }
					Return ResolveState(Null);
				}
				Else
				{
					if(invoker.KickDir > 0) { A_FireProjectile("DeadmakerKickProjectileRight",0,0); }
					else					{ A_FireProjectile("DeadmakerKickProjectileLeft",0,0); }
					Return ResolveState(Null);
				}
			}
			
			//Do we have powersuit?
			If(CountInv("PowerSuitToken"))
			{
				//Cool, we do!... spawn the extra dust stuff.
				A_SpawnItemEx("RoundhouseKickoutSpawner",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS);
				
				//Do we have berserk?
				If(CountInv("PowerBerserkDamage"))
				{
					//Do we have midas?
					If(CountInv("PowerMidasMode"))
					{
						if(invoker.KickDir > 0) { A_FireProjectile("SuperPowerMidasKickProjectileRight",0,0); }
						else					{ A_FireProjectile("SuperPowerMidasKickProjectileLeft",0,0); }
						Return ResolveState(Null);
					}
					Else
					{
						if(invoker.KickDir > 0) { A_FireProjectile("SuperPowerKickProjectileRight",0,0); }
						else					{ A_FireProjectile("SuperPowerKickProjectileLeft",0,0); }
						Return ResolveState(Null);
					}
				}
				//So we have only midas and powersuit.
				If(CountInv("PowerMidasMode"))
				{
					if(invoker.KickDir > 0) { A_FireProjectile("PowerMidasKickProjectileRight",0,0); }
					else					{ A_FireProjectile("PowerMidasKickProjectileLeft",0,0); }
					Return ResolveState(Null);
				}
				Else //Or just powersuit.
				{
					if(invoker.KickDir > 0) { A_FireProjectile("PowerKickProjectileRight",0,0); }
					else					{ A_FireProjectile("PowerKickProjectileLeft",0,0); }
					Return ResolveState(Null);
				}
			}
			
			//Perhaps we have berserk?
			If(CountInv("PowerBerserkDamage"))
			{
				//...And midas?
				If(CountInv("PowerMidasMode"))
				{
					//Okay, and the Draugh.
					If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
					{
						if(invoker.KickDir > 0) { A_FireProjectile("SuperMidasFootProjectileRight",0,0); }
						else 					{ A_FireProjectile("SuperMidasFootProjectileLeft",0,0); }
						Return ResolveState(Null);
					}
					Else
					{
						A_FireProjectile("SuperMidasKickProjectileLeft",0,0);
						Return ResolveState(Null);
					}
				}
				Else
				{
					If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
					{
						if(invoker.KickDir > 0) { A_FireProjectile("SuperFootProjectileRight",0,0); }
						else					{ A_FireProjectile("SuperFootProjectileLeft",0,0); }
						Return ResolveState(Null);
					}
					Else
					{
						if(invoker.KickDir > 0) { A_FireProjectile("SuperKickProjectileRight",0,0); }
						else					{ A_FireProjectile("SuperKickProjectileLeft",0,0); }
						Return ResolveState(Null);
					}
				}
			}
			
			//Or just midas alone?
			If(CountInv("PowerMidasMode"))
			{
				If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
				{
					if(invoker.KickDir > 0) { A_FireProjectile("MidasFootProjectileRight",0,0); }
					else					{ A_FireProjectile("MidasFootProjectileLeft",0,0); }
					Return ResolveState(Null);
				}
				Else
				{
					if(invoker.KickDir > 0) { A_FireProjectile("MidasKickProjectileRight",0,0); }
					else					{ A_FireProjectile("MidasKickProjectileLeft",0,0); }
					Return ResolveState(Null);
				}
			}
			Else //Standard kick it is, then.
			{
				If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
				{
					if(invoker.KickDir > 0) { A_FireProjectile("FootProjectileRight",0,0); }
					else					{ A_FireProjectile("FootProjectileLeft",0,0); }
					Return ResolveState(Null);
				}
				Else
				{
					if(invoker.KickDir > 0) { A_FireProjectile("KickProjectileRight",0,0); }
					else					{ A_FireProjectile("KickProjectileLeft",0,0); }
					Return ResolveState(Null);
				}
			}
			Return ResolveState(Null);
		}
		"####" "#" 1 { A_OverlayOffset(-9,64,70,WOF_INTERPOLATE);	if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); } }
		"####" "#" 1 { A_OverlayOffset(-9,4,72,WOF_INTERPOLATE);	if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.97); } }
		"####" "#" 1 { A_OverlayOffset(-9,-64,82,WOF_INTERPOLATE);  if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.98); } }
		"####" "#" 1 { A_OverlayOffset(-9,-100,96,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.99); } }
		TNT1 A 12 { SetPlayerProperty(0,0,PROP_FROZEN);	invoker.WeapAction--; A_TakeInventory("KickethThyHappend"); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.0); } }
		Goto KickActive;
		
	StomperFire:
		TNT1 A 0 { A_OverlayFlags(OverlayID(),PSPF_FLIP|PSPF_MIRROR,0); SetPlayerProperty(0,1,PROP_FROZEN); invoker.WeapAction++; }
		DSTP G 0 A_JumpIf(CountInv("PowerDeadmaker") && CountInv("PowerSuitDraugh"),7);
		DSTP F 0 A_JumpIfInventory("PowerDeadmaker",1,6);
		DSTP E 0 A_JumpIfInventory("PowerSuitToken",1,5);
		DSTP D 0 A_JumpIfInventory("PowerSuitProtect",1,4);
		DSTP C 0 A_JumpIfInventory("PowerSuitDraugh",1,3);
		DSTP B 0 A_JumpIfInventory("PowerMidasMode",1,2);
		DSTP A 0;
		"####" "#" 1 { A_OverlayOffset(OverlayID(),-42,32); 				A_SetPitch(pitch-0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.995); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),-32,14,WOF_INTERPOLATE); A_SetPitch(pitch-0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.99); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),-21,-6,WOF_INTERPOLATE); A_SetPitch(pitch-0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.985); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),-8,-20,WOF_INTERPOLATE); A_SetPitch(pitch-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.98); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),-3,-25,WOF_INTERPOLATE); A_SetPitch(pitch-2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.97); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),0,-29,WOF_INTERPOLATE); A_SetPitch(pitch-3.15 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),3,-31,WOF_INTERPOLATE); A_SetPitch(pitch-2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.95); } }
		"####" "#" 6 { A_OverlayOffset(OverlayID(),5,-32,WOF_INTERPOLATE); A_SetPitch(pitch-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); }
		"####" "#" 0 {
			if(CountInv("PowerDeadmaker"))
			{
				A_AlertMonsters(256);
				A_PlaySound("Deadmaker/Woosh",1);
				If(CountInv("PowerBerserkDamage"))
				{
					A_GiveInventory("DeadSuckerKick");
				}
			}
			Else if(CountInv("PowerSuitToken"))
			{
				A_AlertMonsters(256);
				A_PlaySound("Bishop/Kick",1,0.9);
				If(CountInv("PowerBerserkDamage"))
				{
					A_GiveInventory("PowerSuckerKick");
				}
			}
			Else If(CountInv("PowerBerserkDamage"))
			{
				A_GiveInventory("SuckerKick");
				A_PlaySound("SuperKick/Init",1,0.9);
			}
			Else
			{
				A_PlaySound("Kick/Init",1,0.7);
			}
			
			if((!CountInv("PowerSuitToken") && !CountInv("PowerSuitProtect")) && CountInv("PowerSuitDraugh"))
			{
				A_PlaySound("Draughcaster/Move",5,0.6);
			}
			else if(!CountInv("PowerSuitToken"))
			{
				A_PlaySound("Kick/Extra",5,0.7);
			}
			if(random(1,4) == 1) { A_PlaySound("Guncaster/Kick",2); }
		}
		"####" "#" 1 { A_OverlayOffset(OverlayID(),7,-30,WOF_INTERPOLATE); A_SetPitch(pitch+1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),16,-15,WOF_INTERPOLATE); A_SetPitch(pitch+4.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.99); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),24,2,WOF_INTERPOLATE); A_SetPitch(pitch+5.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.03); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),36,24,WOF_INTERPOLATE); A_SetPitch(pitch+6.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.07); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),40,33,WOF_INTERPOLATE); A_SetPitch(pitch+3.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.1); } }
		TNT1 A 1 { A_SetPitch(pitch+1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); }
		TNT1 A 0 {
			if(player.OnGround) {
			if(CountInv("HeavyDutyStompers")) {
				A_FireProjectile("ImpalerLiner",0,0);
			}
			
			//Deadmaker block.
			if(CountInv("PowerDeadmaker"))
			{
				if(CountInv("PowerMidasMode"))
				{
					A_SpawnItemEx("MidasDeadmakerStomp",32,0,0,0,0,0,0,SXF_SETTARGET);
					return resolvestate(null);
				}
				A_SpawnItemEx("DeadmakerStomp",32,0,0,0,0,0,0,SXF_SETTARGET);
				return resolvestate(null);
			}
			
			//Powersuit block.
			if(CountInv("PowersuitToken"))
			{
				if(CountInv("PowerMidasMode"))
				{
					if(CountInv("PowerBerserkDamage"))
					{
						A_SpawnItemEx("PowerMidasBerserkStomp",32,0,0,0,0,0,0,SXF_SETTARGET);
						return resolvestate(null);
					}
					A_SpawnItemEx("PowerMidasStomp",32,0,0,0,0,0,0,SXF_SETTARGET);
					return resolvestate(null);
				}
				if(CountInv("PowerBerserkDamage"))
					{
					A_SpawnItemEx("PowerBerserkStomp",32,0,0,0,0,0,0,SXF_SETTARGET);
					return resolvestate(null);
				}
				A_SpawnItemEx("PowerStomp",32,0,0,0,0,0,0,SXF_SETTARGET);
				return resolvestate(null);
			}
			
			//Regular block.
			if(CountInv("PowerMidasMode"))
			{
				if(CountInv("PowerBerserkDamage"))
				{
					A_SpawnItemEx("MidasBerserkStomp",32,0,0,0,0,0,0,SXF_SETTARGET);
					return resolvestate(null);
				}
				A_SpawnItemEx("MidasStompityStomp",32,0,0,0,0,0,0,SXF_SETTARGET);
				return resolvestate(null);
			}
			if(CountInv("PowerBerserkDamage"))
			{
				A_SpawnItemEx("BerserkStomp",32,0,0,0,0,0,0,SXF_SETTARGET);
				return resolvestate(null);
			}
			A_SpawnItemEx("StompityStomp",32,0,0,0,0,0,0,SXF_SETTARGET);
			return resolvestate(null);
			}
			return resolvestate(null);
		}
		TNT1 A 1 A_ZoomFactor(1.07);
		TNT1 A 1 { A_SetPitch(pitch-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.06); } }
		TNT1 A 1 { A_SetPitch(pitch-2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.05); } }
		TNT1 A 1 { A_SetPitch(pitch-3.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.04); } }
		TNT1 A 1 { A_SetPitch(pitch-2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.03); } SetPlayerProperty(0,0,PROP_FROZEN); }
		TNT1 A 1 { A_SetPitch(pitch-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.02); } }
		TNT1 A 1 { A_SetPitch(pitch-0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.01); } }
		TNT1 A 1 { A_SetPitch(pitch-0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.005); } }
		TNT1 A 1 { A_SetPitch(pitch-0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.0025); } }
		TNT1 A 0 {invoker.WeapAction--; A_GiveInventory("FootstompDelay"); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.0); } }
		Goto KickActive;
		
	GenocideCutter:
		TNT1 A 0 {
			A_OverlayFlags(OverlayID(),PSPF_FLIP|PSPF_MIRROR,0);
			if(CountInv("PowerSuitToken"))
			{
				A_AlertMonsters(256);
				A_PlaySound("Bishop/Kick",1,0.9);
				If(CountInv("PowerBerserkDamage"))
				{
					A_GiveInventory("PowerSuckerKick");
				}
			}
			Else If(CountInv("PowerBerserkDamage"))
			{
				A_GiveInventory("SuckerKick");
				A_PlaySound("SuperKick/Init",1,0.9);
			}
			Else
			{
				A_PlaySound("Kick/Init",1,0.7);
			}
			
			if((!CountInv("PowerSuitToken") && !CountInv("PowerSuitProtect")) && CountInv("PowerSuitDraugh"))
			{
				A_PlaySound("Draughcaster/Move",5,0.6);
			}
			else if(!CountInv("PowerSuitToken"))
			{
				A_PlaySound("Kick/Extra",5,0.7);
			}
			
			if(random(1,4) == 1) { A_PlaySound("Guncaster/Kick",2); }
		}
		DSTP E 0 A_JumpIfInventory("PowerSuitToken",1,5);
		DSTP D 0 A_JumpIfInventory("PowerSuitProtect",1,4);
		DSTP C 0 A_JumpIfInventory("PowerSuitDraugh",1,3);
		DSTP B 0 A_JumpIfInventory("PowerMidasMode",1,2);
		DSTP A 0;
		"####" "#" 1 A_OverlayOffset(OverlayID(),174,29);
		"####" "#" 1 A_OverlayOffset(OverlayID(),164,11,WOF_INTERPOLATE);
		"####" "#" 1 A_OverlayOffset(OverlayID(),150,-6,WOF_INTERPOLATE);
		"####" "#" 1 A_OverlayOffset(OverlayID(),133,-17,WOF_INTERPOLATE);
		KCCK A 0 A_JumpIf(CountInv("PowerSuitToken"),5);
		KUCK A 0 A_JumpIf(CountInv("PowerSuitProtect"),4);
		KYCK A 0 A_JumpIf(CountInv("PowerSuitDraugh"),3);
		KMCK A 0 A_JumpIf(CountInv("PowerMidasMode"),2);
		KICK A 0;
		"####" B 1 A_OverlayOffset(OverlayID(),91,6);
		"####" "#" 0 {
			//Do we have powersuit?
			If(CountInv("PowerSuitToken"))
			{
				//Cool, we do!... spawn the extra dust stuff.
				A_SpawnItemEx("RoundhouseKickoutSpawner",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS);
				
				//Do we have berserk?
				If(CountInv("PowerBerserkDamage"))
				{
					//Do we have midas?
					If(CountInv("PowerMidasMode"))
					{
						A_FireProjectile("SuperPowerMidasKickProjectile",0,0); //Cutter",0,0);
						Return ResolveState(Null);
					}
					Else
					{
						A_FireProjectile("SuperPowerKickProjectile",0,0); //Cutter",0,0);
						Return ResolveState(Null);
					}
				}
				//So we have only midas and powersuit.
				If(CountInv("PowerMidasMode"))
				{
					A_FireProjectile("PowerMidasKickProjectile",0,0); //Cutter",0,0);
					Return ResolveState(Null);
				}
				Else //Or just powersuit.
				{
					A_FireProjectile("PowerKickProjectile",0,0); //Cutter",0,0);
					Return ResolveState(Null);
				}
			}
			
			//Perhaps we have berserk?
			If(CountInv("PowerBerserkDamage"))
			{
				//...And midas?
				If(CountInv("PowerMidasMode"))
				{
					//Okay, and the Draugh.
					If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
					{
						A_FireProjectile("SuperMidasFootProjectile",0,0); //Cutter",0,0);
						Return ResolveState(Null);
					}
					Else
					{
						A_FireProjectile("SuperMidasKickProjectileLeft",0,0); //Cutter2",0,0);
						Return ResolveState(Null);
					}
				}
				Else
				{
					If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
					{
						A_FireProjectile("SuperFootProjectile",0,0); //Cutter",0,0);
						Return ResolveState(Null);
					}
					Else
					{
						A_FireProjectile("SuperKickProjectile",0,0); //Cutter",0,0);
						Return ResolveState(Null);
					}
				}
			}
			
			//Or just midas alone?
			If(CountInv("PowerMidasMode"))
			{
				If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
				{
					A_FireProjectile("MidasFootProjectile",0,0); //Cutter",0,0);
					Return ResolveState(Null);
				}
				Else
				{
					A_FireProjectile("MidasKickProjectile",0,0); //Cutter",0,0);
					Return ResolveState(Null);
				}
			}
			Else //Standard kick it is, then.
			{
				If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
				{
					A_FireProjectile("FootProjectile",0,0); //Cutter",0,0);
					Return ResolveState(Null);
				}
				Else
				{
					A_FireProjectile("KickProjectile",0,0); //Cutter",0,0);
					Return ResolveState(Null);
				}
			}
			Return ResolveState(Null);
		}
		"####" C 1 { A_OverlayOffset(OverlayID(),112,32,WOF_INTERPOLATE); A_ChangeVelocity(4.0,0,10.0,CVF_RELATIVE); SetPlayerProperty(0,1,PROP_FROZEN); } //Peak
		"####" C 1 A_OverlayOffset(OverlayID(),97,41,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),78,50,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),58,67,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),43,88,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),31,114,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),24,135,WOF_INTERPOLATE);
		"####" C 1 { A_OverlayOffset(OverlayID(),17,161,WOF_INTERPOLATE); SetPlayerProperty(0,0,PROP_FROZEN); }
		TNT1 A 3;
		
		TNT1 A 0 {
			if(CountInv("PowerSuitToken"))
			{
				A_AlertMonsters(256);
				A_PlaySound("Bishop/Kick",1,0.9);
				If(CountInv("PowerBerserkDamage"))
				{
					A_GiveInventory("PowerSuckerKick");
				}
			}
			Else If(CountInv("PowerBerserkDamage"))
			{
				A_GiveInventory("SuckerKick");
				A_PlaySound("SuperKick/Init",1,0.9);
			}
			Else
			{
				A_PlaySound("Kick/Init",1,0.7);
			}
			
			if((!CountInv("PowerSuitToken") && !CountInv("PowerSuitProtect")) && CountInv("PowerSuitDraugh"))
			{
				A_PlaySound("Draughcaster/Move",5,0.6);
			}
			else if(!CountInv("PowerSuitToken"))
			{
				A_PlaySound("Kick/Extra",5,0.7);
			}
		}
		DSTP E 0 A_JumpIfInventory("PowerSuitToken",1,5);
		DSTP D 0 A_JumpIfInventory("PowerSuitProtect",1,4);
		DSTP C 0 A_JumpIfInventory("PowerSuitDraugh",1,3);
		DSTP B 0 A_JumpIfInventory("PowerMidasMode",1,2);
		DSTP A 0;
		"####" "#" 1 A_OverlayOffset(OverlayID(),156,24);
		"####" "#" 1 A_OverlayOffset(OverlayID(),145,3,WOF_INTERPOLATE);
		"####" "#" 1 A_OverlayOffset(OverlayID(),129,-17,WOF_INTERPOLATE);
		KCCK A 0 A_JumpIf(CountInv("PowerSuitToken"),5);
		KUCK A 0 A_JumpIf(CountInv("PowerSuitProtect"),4);
		KYCK A 0 A_JumpIf(CountInv("PowerSuitDraugh"),3);
		KMCK A 0 A_JumpIf(CountInv("PowerMidasMode"),2);
		KICK A 0;
		"####" D 1 A_OverlayOffset(OverlayID(),124,42);
		"####" "#" 0 {
			//Do we have powersuit?
			If(CountInv("PowerSuitToken"))
			{
				//Cool, we do!... spawn the extra dust stuff.
				A_SpawnItemEx("RoundhouseKickoutSpawner",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS);
				
				//Do we have berserk?
				If(CountInv("PowerBerserkDamage"))
				{
					//Do we have midas?
					If(CountInv("PowerMidasMode"))
					{
						A_FireProjectile("SuperPowerMidasKickProjectileLeft",0,0); //Cutter2",0,0);
						Return ResolveState(Null);
					}
					Else
					{
						A_FireProjectile("SuperPowerKickProjectileLeft",0,0); //Cutter2",0,0);
						Return ResolveState(Null);
					}
				}
				//So we have only midas and powersuit.
				If(CountInv("PowerMidasMode"))
				{
					A_FireProjectile("PowerMidasKickProjectileLeft",0,0); //Cutter2",0,0);
					Return ResolveState(Null);
				}
				Else //Or just powersuit.
				{
					A_FireProjectile("PowerKickProjectileLeft",0,0); //Cutter2",0,0);
					Return ResolveState(Null);
				}
			}
			
			//Perhaps we have berserk?
			If(CountInv("PowerBerserkDamage"))
			{
				//...And midas?
				If(CountInv("PowerMidasMode"))
				{
					//Okay, and the Draugh.
					If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
					{
						A_FireProjectile("SuperMidasFootProjectileLeft",0,0); //Cutter2",0,0);
						Return ResolveState(Null);
					}
					Else
					{
						A_FireProjectile("SuperMidasKickProjectileLeft",0,0); //Cutter2",0,0);
						Return ResolveState(Null);
					}
				}
				Else
				{
					If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
					{
						A_FireProjectile("SuperFootProjectileLeft",0,0); //Cutter2",0,0);
						Return ResolveState(Null);
					}
					Else
					{
						A_FireProjectile("SuperKickProjectileLeft",0,0); //Cutter2",0,0);
						Return ResolveState(Null);
					}
				}
			}
			
			//Or just midas alone?
			If(CountInv("PowerMidasMode"))
			{
				If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
				{
					A_FireProjectile("MidasFootProjectileLeft",0,0); //Cutter2",0,0);
					Return ResolveState(Null);
				}
				Else
				{
					A_FireProjectile("MidasKickProjectileLeft",0,0); //Cutter2",0,0);
					Return ResolveState(Null);
				}
			}
			Else //Standard kick it is, then.
			{
				If(CountInv("PowerSuitDraugh") && !CountInv("PowerSuitProtect"))
				{
					A_FireProjectile("FootProjectileLeft",0,0); //Cutter2",0,0);
					Return ResolveState(Null);
				}
				Else
				{
					A_FireProjectile("KickProjectileLeft",0,0); //Cutter2",0,0);
					Return ResolveState(Null);
				}
			}
			Return ResolveState(Null);
		}
		"####" C 1 { A_OverlayOffset(OverlayID(),120,36,WOF_INTERPOLATE); A_ChangeVelocity(4.0,0,12.0,CVF_RELATIVE); } //Peak
		"####" C 1 A_OverlayOffset(OverlayID(),118,34,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),116,33,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),118,34,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),120,36,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),126,46,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),134,61,WOF_INTERPOLATE);
		"####" C 1 { A_OverlayOffset(OverlayID(),142,74,WOF_INTERPOLATE); SetPlayerProperty(0,0,PROP_FROZEN); }
		"####" C 1 A_OverlayOffset(OverlayID(),151,89,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),161,104,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),173,123,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),185,144,WOF_INTERPOLATE);
		"####" C 1 A_OverlayOffset(OverlayID(),195,160,WOF_INTERPOLATE);
		Goto KickFinish;
		
	//////////////
	//CAST START//
	//////////////

	HandCast:
		"####" "#" 0 { invoker.HandCast = 1; }
		Goto Cast;
	StratCast:
		"####" "#" 0 { invoker.StratCast = 1; }
		Goto Cast;
	Cast:
		"####" "#" 0 {
			If(CountInv("SkullfireActive")) 	{ Return ResolveState("SkullfireLaunch"); }
			If(CountInv("FlamewaveActive")) 	{ Return ResolveState("FlamewaveLaunch"); }
			If(CountInv("FrostbiteActive")) 	{ Return ResolveState("FrostbiteLaunch"); }
			If(CountInv("SpiritcannonActive")) 	{ Return ResolveState("SpiritcannonLaunch"); }
			If(CountInv("HammersmiteActive")) 	{ Return ResolveState("HammersmiteLaunch"); }
			If(CountInv("GumpopActive")) 		{ Return ResolveState("GumpopLaunch"); }
			If(CountInv("SkypunchActive")) 		{ Return ResolveState("SkypunchLaunch"); }
			If(CountInv("ThunderActive")) 		{ Return ResolveState("ThunderLaunch"); }
			If(CountInv("CorpseActive")) 		{ Return ResolveState("CorpseLaunch"); }
			If(CountInv("ThreadcutterActive")) 	{ Return ResolveState("ThreadLaunch"); }
			If(CountInv("AnnihilationActive")) 	{ Return ResolveState("AnnihilationLaunch"); }
			If(CountInv("ApocalypseActive")) 	{ Return ResolveState("ApocalypseLaunch"); }
			If(CountInv("DarkpathActive")) 		{ Return ResolveState("DarkpathLaunch"); }
			If(CountInv("CrowsActive")) 		{ Return ResolveState("CrowsLaunch"); }
			If(CountInv("PrismActive"))			{ Return ResolveState("PrismLaunch"); }
			If(CountInv("BreathActive")) 		{ Return ResolveState("BreathLaunch"); }
			If(CountInv("SheepshieldActive")) 	{ Return ResolveState("SheepshieldLaunch"); }
			If(CountInv("ChillgraspActive")) 	{ Return ResolveState("ChillgraspLaunch"); }
			If(CountInv("SigilActive")) 		{ Return ResolveState("SigilLaunch"); }
			
			//Non-standard fitting spells.
			
			If(CountInv("FirebreathActive")) 	{ Return ResolveState("FirebreathLaunch"); }
			If(CountInv("DragonshoutActive")) 	{ Return ResolveState("DragonshoutLaunch"); }
			If(CountInv("MeteorfistActive")) 	{ Return ResolveState("MeteorfistLaunch"); }
			
			Return ResolveState("FuckNo");
		}
	FuckNo:
		"####" "#" 35 {
			A_PlaySound("Spell/Move",5,0.8);
			A_Print("$NOSPELLEQUIPPED");
		}
		"####" "#" 0 A_Jump(256, "LeftActive");
		Goto LeftActive;

	//State for casting delay when you don't have enough mana boosters
	//and try to cast a tomed, powerful spell, so your console won't turn into spamfest.

	Lockdown:
		"####" "#" 35;
		Goto LeftActive;
	
	//When something, somewhere, went terribly wrong.
	
	WaitWhat:
		"####" "#" 0 A_Print("SPAGHETTIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII");
		Goto LeftActive;
		
		
	////////////////
	//LAUNCH START//
	////////////////
	
	FlushTriggers:
		"####" "#" 0 {
			invoker.HandCast = 0;
			invoker.StratCast = 0;
			Return ResolveState("LeftActive");
		}
		Goto LeftActive;

	//SKULLFIRE
	SkullfireLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 30) { A_GiveInventory("SkullfireInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 20) { A_GiveInventory("SkullfireInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
	
	//FLAMEWAVE
	FlamewaveLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 100) { A_GiveInventory("FlamewaveInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 70) { A_GiveInventory("FlamewaveInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
	
	//FROSTBITE
	FrostbiteLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 70) { A_GiveInventory("FrostbiteInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 30) { A_GiveInventory("FrostbiteInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//SPIRITCANNON
	SpiritcannonLaunch:
		"####" "#" 0 {
			If(CountInv("Mana") >= 20) { A_GiveInventory("SpiritcannonInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//HAMMERSMITE
	HammersmiteLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 90) { A_GiveInventory("HammersmiteInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 60) { A_GiveInventory("HammersmiteInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//GUMPOP
	GumpopLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 50) { A_GiveInventory("GumpopInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 10) { A_GiveInventory("GumpopInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//SKYPUNCH
	SkypunchLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 60) { A_GiveInventory("SkypunchInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 40) { A_GiveInventory("SkypunchInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//THUNDERSTRUCK
	ThunderLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 40) { A_GiveInventory("ThunderInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 30) { A_GiveInventory("ThunderInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
	
	//CORPSEBLAST
	CorpseLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 70) { A_GiveInventory("CorpseInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 25) { A_GiveInventory("CorpseInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//THREADCUTTER
	ThreadLaunch:
		"####" A 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 60) { A_GiveInventory("ThreadInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 25) { A_GiveInventory("ThreadInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//ANNIHILATION
	AnnihilationLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 200) { A_GiveInventory("AnnihilationInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 100) { A_GiveInventory("AnnihilationInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//APOCALYPSE
	ApocalypseLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 200) { A_GiveInventory("ApocalypseInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 100) { A_GiveInventory("ApocalypseInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//DARKPATH
	DarkpathLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 45) { A_GiveInventory("DarkpathInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 25) { A_GiveInventory("DarkpathInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//HITCHCOCK'S BIRDS
	CrowsLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 50) { A_GiveInventory("CrowsInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 30) { A_GiveInventory("CrowsInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	//PRISM LAZER
	PrismLaunch:
		"####" "#" 0 {
			If(CountInv("Mana") >= 50) { A_GiveInventory("PrismInProgress"); Return A_Jump(256,1); }
			Return ResolveState("FlushTriggers");
		}
		Goto FlushTriggers;
		"####" "#" 0 {
			A_SetBlend("White",0.2,25);
			A_TakeInventory("Mana",25,TIF_NOTAKEINFINITE);
			A_GiveInventory("PrismRadius",70);
			A_GiveInventory("PrismSpin",360);
			//A_PlaySound("Prism/Start",5,0.7);
			A_QuakeEx(1,1,1,9,0,128,"none",QF_SCALEUP);
			
			A_SpawnItemEx("PrismLightBlue",192,0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_SETTARGET|SXF_NOCHECKPOSITION);
			A_SpawnItemEx("PrismLightCyan",192,0,0,0,0,0,45,SXF_CLIENTSIDE|SXF_SETTARGET|SXF_NOCHECKPOSITION);
			A_SpawnItemEx("PrismLightGreen",192,0,0,0,0,0,90,SXF_CLIENTSIDE|SXF_SETTARGET|SXF_NOCHECKPOSITION);
			A_SpawnItemEx("PrismLightLime",192,0,0,0,0,0,135,SXF_CLIENTSIDE|SXF_SETTARGET|SXF_NOCHECKPOSITION);
			A_SpawnItemEx("PrismLightYellow",192,0,0,0,0,0,180,SXF_CLIENTSIDE|SXF_SETTARGET|SXF_NOCHECKPOSITION);
			A_SpawnItemEx("PrismLightOrange",192,0,0,0,0,0,225,SXF_CLIENTSIDE|SXF_SETTARGET|SXF_NOCHECKPOSITION);
			A_SpawnItemEx("PrismLightRed",192,0,0,0,0,0,270,SXF_CLIENTSIDE|SXF_SETTARGET|SXF_NOCHECKPOSITION);
			A_SpawnItemEx("PrismLightPurple",192,0,0,0,0,0,315,SXF_CLIENTSIDE|SXF_SETTARGET|SXF_NOCHECKPOSITION);
			
			if(!Invoker.Prism) {
				Invoker.Prism = new("Gc_Prism");
			}
			
			if(random(1,100) <= GetCvar("GC_PrismRave")) { A_PlaySound("Prism/RaveParty",1,1.0,1); }
		}
		Goto CastLaunch;
		
	//SCOURGEBREATH
	BreathLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 16) { A_GiveInventory("BreathInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 24) { A_GiveInventory("BreathInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
	BreathKickstart:
		TNT1 A 10 A_PlaySound("Breath/Start",6,0.8);
		Goto CastLaunchMain;
	
	//SHEEPSHIELD
	SheepshieldLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect") && CountInv("SuperSheepOut") >= 3)
			{
				Return ResolveState("LeftActive");
			}
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 100) { A_GiveInventory("SheepshieldInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 25) { A_GiveInventory("SheepshieldInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
	
	//CHILLGRASP
	ChillgraspLaunch:
		"####" "#" 0 {
			If(CountInv("Mana") >= 25) { A_GiveInventory("ChillgraspInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
		}
		
	//SIGIL OF THE GODS
	SigilLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 60) { A_GiveInventory("SigilInProgress"); Return ResolveState("CastLaunch"); }
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 70) { A_GiveInventory("SigilInProgress"); Return ResolveState("CastLaunch"); }
			Return ResolveState("FlushTriggers");
		}
		
	///////////////
	//CAST LAUNCH//
	///////////////
	
	CastLaunch:
		"####" "#" 0 { invoker.WeapAction++; invoker.LeftHand = 1; }
		"####" "#" 0 A_JumpIf(invoker.HandCast,"CastHandLaunch");
		"####" "#" 0 A_JumpIf(invoker.StratCast,"CastStratLaunch");
		"####" "#" 0 { If(CountInv("FrostbiteInProgress")) { A_PlaySound("Frostbite/Spell",6); } }
		"####" "#" 0 { If(CountInv("PrismInProgress")) { A_PlaySound("Prism/Start",5,0.7); } }
		"####" "#" 0 { If(CountInv("BreathInProgress")) { Return ResolveState("BreathKickstart"); } Return ResolveState(null); }
		"####" "#" 0 { If(CountInv("SheepshieldInProgress")) { A_PlaySound("Sheepshield/Launch",5); } }
		Goto CastLaunchMain;
	CastLaunchMain:
		CYDH C 0 A_JumpIf(CountInv("PowerDeadmaker") && CountInv("PowerSuitDraugh"),6);
		CYNH C 0 A_JumpIf(CountInv("PowerDeadmaker"),5);
		CYCH C 0 A_JumpIf(CountInv("PowerSuitToken"),4);
		CYUH C 0 A_JumpIf(CountInv("PowerSuitProtect"),3);
		CYYH C 0 A_JumpIf(CountInv("PowerSuitDraugh"),2);
		CYGH C 0;
		"####" "#" 1   A_OverlayOffset(3,2,190);
		"####" "#" 1   A_OverlayOffset(3,9,182,WOF_INTERPOLATE);
		"####" "#" 1   A_OverlayOffset(3,17,165,WOF_INTERPOLATE);
		"####" "#" 1 { A_OverlayOffset(3,19,142,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.99); } }
		"####" "#" 1 { A_OverlayOffset(3,21,118,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.98); } }
		"####" "#" 1 { A_OverlayOffset(3,18,98,WOF_INTERPOLATE);  if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.97); } }
		"####" "#" 1 { A_OverlayOffset(3,12,79,WOF_INTERPOLATE);  if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); } }
		"####" "#" 1 { A_OverlayOffset(3,10,67,WOF_INTERPOLATE);  if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.95); } }
		"####" "#" 1 { A_OverlayOffset(3,8,64,WOF_INTERPOLATE);	  if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.94); } }
	SheepshieldInit:
		"####" "#" 0 { If(CountInv("SheepshieldInProgress")) {
			If(CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",100,TIF_NOTAKEINFINITE);
			}
			Else
			{
				A_TakeInventory("Mana",25,TIF_NOTAKEINFINITE);
			}
			A_GiveInventory("SheepActive",1); } }
		Goto CastLoop;
		
	/////////////	
	//CAST LOOP//
	/////////////
	
	
	CastLoop:
		"####" "#" 0 A_JumpIf(CountInv("SkullfireInProgress"),"SkullfireLoop");
		"####" "#" 0 A_JumpIf(CountInv("FlamewaveInProgress"),"FlamewaveLoop");
		"####" "#" 0 A_JumpIf(CountInv("FrostbiteInProgress"),"FrostbiteLoop");
		"####" "#" 0 A_JumpIf(CountInv("SpiritcannonInProgress"),"SpiritcannonLoop");
		"####" "#" 0 A_JumpIf(CountInv("HammersmiteInProgress"),"HammersmiteLoop");
		"####" "#" 0 A_JumpIf(CountInv("GumpopInProgress"),"GumpopLoop");
		"####" "#" 0 A_JumpIf(CountInv("SkypunchInProgress"),"SkypunchLoop");
		"####" "#" 0 A_JumpIf(CountInv("ThunderInProgress"),"ThunderLoop");
		"####" "#" 0 A_JumpIf(CountInv("CorpseInProgress"),"CorpseLoop");
		"####" "#" 0 A_JumpIf(CountInv("ThreadInProgress"),"ThreadLoop");
		"####" "#" 0 A_JumpIf(CountInv("AnnihilationInProgress"),"AnnihilationLoop");
		"####" "#" 0 A_JumpIf(CountInv("ApocalypseInProgress"),"ApocalypseLoop");
		"####" "#" 0 A_JumpIf(CountInv("DarkpathInProgress"),"DarkpathLoop");
		"####" "#" 0 A_JumpIf(CountInv("CrowsInProgress"),"CrowsLoop");
		"####" "#" 0 A_JumpIf(CountInv("PrismInProgress"),"PrismLoop");
		"####" "#" 0 A_JumpIf(CountInv("BreathInProgress"),"BreathLoop");
		"####" "#" 0 A_JumpIf(CountInv("SheepshieldInProgress"),"SheepshieldLoop");
		"####" "#" 0 A_JumpIf(CountInv("ChillgraspInProgress"),"ChillgraspLoop");
		"####" "#" 0 A_JumpIf(CountInv("SigilInProgress"),"SigilLoop");
		Goto WaitWhat;
	
	//SKULLFIRE
	SkullfireLoop:
		"####" "#" 0 {
			A_PlaySound("Skullfire/Launch",0);
			A_AlertMonsters();
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",20,TIF_NOTAKEINFINITE);
				A_FireProjectile("SkullfireProjectile",0,0,-12,0);
				A_SetBlend("Orange",0.1,15);
			}
			Else
			{
				A_TakeInventory("Mana",30,TIF_NOTAKEINFINITE);
				A_FireProjectile("SkullfireTomedProjectile",0,0,-12,0);
				A_PlaySound("Skullfire/Whizz",6,0.55);
				A_SetBlend("Orange",0.2,25,"Red");
			}
			Return ResolveState("CastLoopMain");
		}
	
	//FLAMEWAVE
	FlamewaveLoop:
		"####" "#" 0 {
			A_PlaySound("Skullfire/Launch",0);
			A_AlertMonsters();
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",70,TIF_NOTAKEINFINITE);
				A_FireProjectile("FlamewaveSpawner",0,0,-12);
				A_SetBlend("Orange",0.1,15);
			}
			Else
			{
				A_TakeInventory("Mana",100,TIF_NOTAKEINFINITE);
				A_FireProjectile("SuperFlamewaveSpawner",0,0,-12);
				A_PlaySound("Skullfire/Whizz",6,0.55);
				A_SetBlend("Orange",0.1,15,"Red");
			}
			Return ResolveState("CastLoopMain");
		}
		
	//FROSTBITE
	FrostbiteLoop:
		"####" "#" 0 {
			A_PlaySound("Frostbite/Launch",5);
			A_AlertMonsters();
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",30,TIF_NOTAKEINFINITE);
				A_FireProjectile("FrostbiteProjectile",0,0,-12);
				A_PlaySound("Frostbite/Launch",5);
				A_SetBlend("Blue",0.1,15);
			}
			Else
			{
				A_TakeInventory("Mana",70,TIF_NOTAKEINFINITE);
				A_FireProjectile("FrozenOrbProjectile",0,0,-12);
				A_SetBlend("White",0.2,20,"Blue");
			}
			Return ResolveState("CastLoopMain");
		}
		
	//SPIRITCANNON
	SpiritcannonLoop:
		"####" "#" 0 {
			A_TakeInventory("Mana",20,TIF_NOTAKEINFINITE);
			A_AlertMonsters();
			A_PlaySound("Spiritcannon/Use",0);
			A_SetBlend("LightBlue",0.1,25);
			If(!CountInv("PowerTomeEffect"))
			{
				//A_SpawnItemEx("SpiritCannonSpawner",0,0,height*0.6,cos(pitch)*300,0,-sin(pitch)*300,0,SXF_TRANSFERTRANSLATION|SXF_TRANSFERPOINTERS);
				Actor SpawnedCannon = A_FireProjectile("SpiritCannonSpawner",0,0,-12);
				if(multiplayer && SpawnedCannon) SpawnedCannon.Translation = self.Translation;
			}
			Else
			{
				//A_SpawnItemEx("FloaterCannonSpawner",0,0,height*0.6,cos(pitch)*300,0,-sin(pitch)*300,0,SXF_TRANSFERTRANSLATION|SXF_TRANSFERPOINTERS);
				Actor SpawnedCannon = A_FireProjectile("FloaterCannonSpawner",0,0,-12);
				if(multiplayer && SpawnedCannon) SpawnedCannon.Translation = self.Translation;
			}
			Return ResolveState("CastLoopMain");
		}
		
	//HAMMERSMITE
	HammersmiteLoop:
		"####" "#" 0 {
			A_AlertMonsters();
			A_PlaySound("Hammersmite/Use",5);
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",60,TIF_NOTAKEINFINITE);
				A_SetBlend("Yellow",0.1,25);
				A_FireProjectile("HammersmiteProjectile",0,0,-12,0);
			}
			Else
			{
				A_TakeInventory("Mana",90,TIF_NOTAKEINFINITE);
				A_SetBlend("Yellow",0.1,25,"White");
				A_FireProjectile("HammersmiteProjectileTomed",0,0,-12,0);
			}
			Return ResolveState("CastLoopMain");
		}
		
	//GUMPOP
	GumpopLoop:
		"####" "#" 0 {
			A_AlertMonsters();
			A_PlaySound("Gumpop/Cast",5,0.6);
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",10,TIF_NOTAKEINFINITE);
				A_SetBlend("Green",0.1,12);
				A_FireProjectile("GumpopProjectile",0,0,-12,0);
			}
			Else
			{
				A_TakeInventory("Mana",50,TIF_NOTAKEINFINITE);
				A_SetBlend("Green",0.1,18);
				A_FireProjectile("GumpopProjectile2",0,0,-12,0);
			}
			Return ResolveState("CastLoopMain");
		}
		
	//SKYPUNCH
	SkypunchLoop:
		"####" "#" 0 {
			A_AlertMonsters();
			A_PlaySound("Skypunch/Layer",6,0.9);
			A_PlaySound("Skypunch/Blast",5,1.0);
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",40,TIF_NOTAKEINFINITE);
				A_SetBlend("White",0.1,12);
				A_FireProjectile("SkypunchWave",0,0,-12,0);
			}
			Else
			{
				A_TakeInventory("Mana",60,TIF_NOTAKEINFINITE);
				A_SetBlend("White",0.2,15);
				A_FireProjectile("SkypunchLauncher2",0,0,-12,0);
			}
			Return ResolveState("CastLoopMain");
		}
		
	//THUNDERSTRUCK
	ThunderLoop:
		"####" "#" 0 {
			A_AlertMonsters();
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",30,TIF_NOTAKEINFINITE);
				A_FireProjectile("ThunderSpawner",0,0,-12,0);
				A_PlaySound("Thunderstruck/Use",5,0.9);
				A_SetBlend("Yellow",0.2,15);
			}
			Else If(CountInv("StormEngaged"))
			{
				A_SetBlend("Yellow",0.2,25);
				A_PlaySound("Thunderstorm/Stop",5,0.9);
				A_GiveInventory("StormTrigger");
			}
			Else
			{
				A_TakeInventory("Mana",40,TIF_NOTAKEINFINITE);
				A_SpawnItemEx("RajtninguStormuru",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION|SXF_SETTARGET,0);
				A_PlaySound("thundertome_active",5,1);
				A_SetBlend("Yellow",0.4,50,"White");
				
			}
			Return ResolveState("CastLoopMain");
		}
		
	//CORPSEBLAST
	CorpseLoop:
		"####" "#" 0 {
			A_AlertMonsters();
			A_PlaySound("Corpseblast/Use",5);
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",25,TIF_NOTAKEINFINITE);
				//"A_FireProjectile("CorpseEffect",0,0,0,0);
				//A_RadiusGive("CorpseBlaster", 96, RGF_MONSTERS|RGF_CORPSES, 1);
				A_FireProjectile("CorpseblastProjectile",0,0,-12,0);
				A_SetBlend("Red",0.1,15);
			}
			Else
			{
				A_TakeInventory("Mana",70,TIF_NOTAKEINFINITE);
				//A_FireProjectile("CorpseEffect",0,0,0,0);
				//A_RadiusGive("CorpseBlaster2", 96, RGF_MONSTERS|RGF_CORPSES, 1);
				A_FireProjectile("CorpseblastProjectile2",0,0,-12,0);
				A_PlaySound("Corpseblast/Use",5);
				A_SetBlend("Red",0.2,20);
			}
			Return ResolveState("CastLoopMain");
		}
		
	//THREADCUTTER
	ThreadLoop:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"),"ThreadLoopTomed");
		"####" "#" 0 {
			A_AlertMonsters();
			A_PlaySound("Threadcutter/Use",1|CHAN_NOPAUSE,0.9);
			A_SetBlend("Cyan",0.1,25);
			A_TakeInventory("Mana",25,TIF_NOTAKEINFINITE);
			for(invoker.Loopler = 0; invoker.Loopler <= 20; invoker.Loopler++)
			{
				A_FireProjectile("ThreadcutterKnife1",frandom(7.5,-7.5),0,-16+frandom(4.0,-4.0),-4+frandom(4.0,-4.0),0,frandom(3.5,-3.5));
			}
			for(invoker.Loopler = 0; invoker.Loopler <= 10; invoker.Loopler++)
			{
				A_FireProjectile("ThreadcutterCleaver1",frandom(7.5,-7.5),0,-16+frandom(4.0,-4.0),-4+frandom(4.0,-4.0),0,frandom(3.5,-3.5));
			}
		}
		Goto CastLoopMain;
	ThreadLoopTomed:
		"####" "#" 0 {
			A_AlertMonsters();
			A_GiveInventory("Dio",1);
			A_PlaySound("Threadcutter/Loop",5|CHAN_NOPAUSE,0.9,1);
			A_PlaySound("Threadcutter/Use",1|CHAN_NOPAUSE,0.9);
			A_SetBlend("Cyan",0.1,35);
			A_TakeInventory("Mana",60,TIF_NOTAKEINFINITE);
			for(invoker.Loopler = 0; invoker.Loopler <= 20; invoker.Loopler++)
			{
				A_FireProjectile("ThreadcutterKnife2",frandom(7.5,-7.5),0,-16+frandom(4.0,-4.0),-4+frandom(4.0,-4.0),0,frandom(3.5,-3.5));
			}
			for(invoker.Loopler = 0; invoker.Loopler <= 10; invoker.Loopler++)
			{
				A_FireProjectile("ThreadcutterCleaver2",frandom(7.5,-7.5),0,-16+frandom(4.0,-4.0),-4+frandom(4.0,-4.0),0,frandom(3.5,-3.5));
			}
		}
		Goto CastLoopMain;
		
	//ANNIHILATION
	AnnihilationLoop:
		"####" "#" 0 {
			A_AlertMonsters();
			A_PlaySound("Annihilation/Use",5,0.8);
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",100,TIF_NOTAKEINFINITE);
				A_FireProjectile("AnnihilationShot",0,0,-12,0);
				A_SetBlend("Blue",0.3,55);
			}
			Else
			{
				A_TakeInventory("Mana",200,TIF_NOTAKEINFINITE);
				A_PlaySound("Annihilation/Hit3",6,0.8);
				A_FireProjectile("TomedAnnihilationShot",0,0,-12,0);
				A_SetBlend("White",0.4,55,"Blue");
			}
			Return ResolveState("CastLoopMain");
		}
		
	//APOCALYPSE
	ApocalypseLoop:
		"####" "#" 0 {
			A_AlertMonsters();
			A_FireProjectile("CorpseEffect",0,0,0,0); //Salvaged that effect for this instead.
			A_PlaySound("Apocalypse/Use",5);
			A_PlaySound("Apocalypse/Aftermath",6);
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",100,TIF_NOTAKEINFINITE);
				A_TracerSpray("ApocalypseBlastMinor",20,0,90,2048,48,20); //A_FireProjectile("ApocalypseMinor",0,0);
				A_SetBlend("Red",0.4,70);
				A_QuakeEx(1,1,2,35,0,32,"none",QF_SCALEDOWN);
			}
			Else
			{
				A_TakeInventory("Mana",200,TIF_NOTAKEINFINITE);
				A_TracerSpray("ApocalypseBlastMajor",12,0,90,2048,48,50); //A_FireProjectile("ApocalypseMajor",0,0);
				A_SetBlend("Red",0.4,70,"Black");
				A_QuakeEx(2,2,3,35,0,32,"none",QF_SCALEDOWN);
			}
			Return ResolveState("CastLoopMain");
		}
		
	//DARKPATH
	DarkpathLoop:
		"####" "#" 2 {
			A_OverlayOffset(3,18,74,WOF_INTERPOLATE);
			A_AlertMonsters();
			A_PlaySound("Darkpath/Use",1|CHAN_NOPAUSE,0.9);
			If(!CountInv("PowerTomeEffect"))
			{
				A_PlaySound("Darkpath/Use",1|CHAN_NOPAUSE,0.9);
				A_TakeInventory("Mana",25,TIF_NOTAKEINFINITE);
				A_FireProjectile("DarkpathIn",0,0);
				A_FireBullets(0,0,1,0,"DarkpathPuff",FBF_NORANDOMPUFFZ,32768);
			}
			Else
			{
				A_TakeInventory("Mana",45,TIF_NOTAKEINFINITE);
				A_GiveInventory("DarkpathTime");
				A_FireBullets(0,0,1,0,"DarkpathPuff2",FBF_NORANDOMPUFFZ,32768);
				A_RailAttack(0,0,0,"","purple",RGF_SILENT,0.0,"DarkpathPuffRail",0,0,0,0,24.0,0,"DarkpathRail");
			}
		}
		"####" "#" 0 { if(!CountInv("PowerTomeEffect")) {
				A_FireProjectile("DarkpathSlash",0,0);
				A_FireProjectile("DarkpathSlash2",0,0);
			}
		}
		Goto CastLoopMain;
		
	//CROWS
	CrowsLoop:
		"####" "#" 0 {
			A_AlertMonsters();
			A_PlaySound("Crows/Launch",5,0.8);
			A_PlaySound("Crows/Scream",6,0.4);
			A_PlaySound("Crows/Add",1,0.7);
			A_SetBlend("Black",0.3,35);
			If(!CountInv("PowerTomeEffect"))
			{
				A_Overlay(9,"CrowLaunch");
				A_TakeInventory("Mana",30,TIF_NOTAKEINFINITE);
			}
			Else
			{
				A_TakeInventory("Mana",50,TIF_NOTAKEINFINITE);
				A_Overlay(9,"TCrowLaunch");
			}
			Return ResolveState("CastLoopMain");
		}
	CrowLaunch:
		TNT1 AAAAAAAAAAAAAAA 1 A_FireProjectile("CrowLauncher2",0,0,-12,0);
		Stop;
	TCrowLaunch:
		TNT1 AAAAAAAAAAAAAAA 1 A_FireProjectile("CrowLauncher",0,0,-12,0);
		Stop;

	//PRISM LAZER
	PrismLoop:
		
		"####" "#" 0 {
			Gc_PrismRaveHandler.StartLocalRave(invoker.PlayerNumber());
			
			Invoker.Prism.Start(
				player.mo,
				count:		8,
				start_rad:	1,	// Start opening size (sine of angle) / final
				end_rad:	0,	// (1 means 45°, higher will go towards 90°)
				start_w:	50,	// Disc radius when appearing / final
				end_w:		8,
				start_s:	0,	// Scale when appearing / final
				end_s:		12.5,
				offset_h: -20,
				attackzoffset: -16
				);
		}
		
	PrismRealLoop:
		"####" "#" 0 A_PlaySound("Prism/Loop",6,1.0,1);
		"####" "#" 0 A_JumpIfInventory("PowerTomeEffect",1,3);
		"####" "#" 0 A_JumpIf(CountInv("PrismPower") < 70,2);
		"####" "#" 0 A_JumpIfInventory("Mana",2,2);
		Goto PrismEnd;
		"####" "#" 0 A_JumpIfInventory("Mana",1,1);
		Goto PrismEnd;
		"####" "#" 0 A_JumpIfInventory("PowerTomeEffect",1,3);
		"####" "#" 0 A_JumpIf(CountInv("PrismPower") < 70,2);
		"####" "##" 0 A_TakeInventory("Mana",random(1,2),TIF_NOTAKEINFINITE);

		"####" "#" 0 A_GiveInventory("PrismPower",1); 		 // Increases power consumption after hitting some point.
		/*"####" "#" 0 A_JumpIf(CountInv("PrismRadius") < 2,2); // Make sure we wind up with one in the end.
		"####" "#" 0 A_TakeInventory("PrismRadius",1); 		 // Skipped when only one is left.
		"####" "#" 0 A_TakeInventory("PrismSpin",10); 		 // Go ten degrees at a time.
		"####" "#" 0 A_JumpIfInventory("PrismSpin",1,2); 	 // Make sure we loop over the spin amounts.
		"####" "#" 0 A_GiveInventory("PrismSpin",360);*/
		"####" "#" 0 A_AlertMonsters();
		
		// kd: I kept the inventory stuff around for now!
		
		"####" "#" 1 Bright {
			A_OverlayOffset(3,-2 + frandom(4.0,-4.0),74  + frandom(4.0,-4.0),WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.9); }
			A_QuakeEx(1,1,1,25,0,128,"none",QF_SCALEDOWN);
			Invoker.Prism.Tick(
				player.mo,
				rot_speed: 10,		// Spin speed in degrees per tic
				closing_f: 0.07,	// Higher means faster closing rate
				scaling_f: 0.15);	// Higher means reaches max width faster
		}
	  
		/* Projectile version. Lags less and works with wyverns, but gets weird, eggy shape.
		"####" "#" 0 A_FireProjectile("PrismProjectileBlue",atan(sin(CountInv("PrismSpin") + 0.0) * CountInv("PrismRadius") / 70),0,0,0,0, atan(cos(CountInv("PrismSpin") + 0.0) * CountInv("PrismRadius") / 70))
		"####" "#" 0 A_FireProjectile("PrismProjectileCyan",atan(sin(CountInv("PrismSpin") + 45.0) * CountInv("PrismRadius") / 70),0,0,0,0, atan(cos(CountInv("PrismSpin") + 45.0) * CountInv("PrismRadius") / 70))
		"####" "#" 0 A_FireProjectile("PrismProjectileLime",atan(sin(CountInv("PrismSpin") + 90.0) * CountInv("PrismRadius") / 70),0,0,0,0, atan(cos(CountInv("PrismSpin") + 90.0) * CountInv("PrismRadius") / 70))
		"####" "#" 0 A_FireProjectile("PrismProjectileLime",atan(sin(CountInv("PrismSpin") + 135.0) * CountInv("PrismRadius") / 70),0,0,0,0, atan(cos(CountInv("PrismSpin") + 135.0) * CountInv("PrismRadius") / 70))
		"####" "#" 0 A_FireProjectile("PrismProjectileYellow",atan(sin(CountInv("PrismSpin") + 180.0) * CountInv("PrismRadius") / 70),0,0,0,0, atan(cos(CountInv("PrismSpin") + 180.0) * CountInv("PrismRadius") / 70))
		"####" "#" 0 A_FireProjectile("PrismProjectileOrange",atan(sin(CountInv("PrismSpin") + 225.0) * CountInv("PrismRadius") / 70),0,0,0,0, atan(cos(CountInv("PrismSpin") + 225.0) * CountInv("PrismRadius") / 70))
		"####" "#" 0 A_FireProjectile("PrismProjectileRed",atan(sin(CountInv("PrismSpin") + 270.0) * CountInv("PrismRadius") / 70),0,0,0,0, atan(cos(CountInv("PrismSpin") + 270.0) * CountInv("PrismRadius") / 70))
		"####" "#" 0 A_FireProjectile("PrismProjectilePurple",atan(sin(CountInv("PrismSpin") + 315.0) * CountInv("PrismRadius") / 70),0,0,0,0, atan(cos(CountInv("PrismSpin") + 315.0) * CountInv("PrismRadius") / 70))
		*/
	  
		/*"####" "#" 1 Bright {
			A_OverlayOffset(3,-2 + frandom(4.0,-4.0),74  + frandom(4.0,-4.0),WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.9); }
			A_QuakeEx(1,1,1,25,0,128,"none",QF_SCALEDOWN);
			A_RailAttack(CountInv("PrismPower") * 0.2, -5, false, "", "FF0000", RGF_SILENT | RGF_EXPLICITANGLE | RGF_FULLBRIGHT, 0, "PrismImpactBlue",
				atan(sin(CountInv("PrismSpin") + 0.0) * CountInv("PrismRadius") / 70),
				atan(cos(CountInv("PrismSpin") + 0.0) * CountInv("PrismRadius") / 70), 0, 2, 48.0,
				0,"PrismBeamBlue",-5);
			A_RailAttack(CountInv("PrismPower") * 0.2, -5, false, "", "FF8000", RGF_SILENT | RGF_EXPLICITANGLE | RGF_FULLBRIGHT, 0, "PrismImpactCyan",
				atan(sin(CountInv("PrismSpin") + 45.0) * CountInv("PrismRadius") / 70),
				atan(cos(CountInv("PrismSpin") + 45.0) * CountInv("PrismRadius") / 70), 0, 2, 48.0, //7.0 + (CountInv("PrismRadius") * 0.75)
				0,"PrismBeamCyan",-5);
			A_RailAttack(CountInv("PrismPower") * 0.2, -5, false, "", "FFFF00", RGF_SILENT | RGF_EXPLICITANGLE | RGF_FULLBRIGHT, 0, "PrismImpactGreen",
				atan(sin(CountInv("PrismSpin") + 90.0) * CountInv("PrismRadius") / 70),
				atan(cos(CountInv("PrismSpin") + 90.0) * CountInv("PrismRadius") / 70), 0, 2, 48.0,
				0,"PrismBeamGreen",-5);
			A_RailAttack(CountInv("PrismPower") * 0.25, -5, false, "", "00FF00", RGF_SILENT | RGF_EXPLICITANGLE | RGF_FULLBRIGHT, 0, "PrismImpactLime",
				atan(sin(CountInv("PrismSpin") + 135.0) * CountInv("PrismRadius") / 70),
				atan(cos(CountInv("PrismSpin") + 135.0) * CountInv("PrismRadius") / 70), 0, 2, 48.0,
				0,"PrismBeamLime",-5);
			A_RailAttack(CountInv("PrismPower") * 0.2, -5, false, "", "00FFFF", RGF_SILENT | RGF_EXPLICITANGLE | RGF_FULLBRIGHT, 0, "PrismImpactYellow",
				atan(sin(CountInv("PrismSpin") + 180.0) * CountInv("PrismRadius") / 70),
				atan(cos(CountInv("PrismSpin") + 180.0) * CountInv("PrismRadius") / 70), 0, 2, 48.0,
				0,"PrismBeamYellow",-5);
			A_RailAttack(CountInv("PrismPower") * 0.2, -5, false, "", "0000FF", RGF_SILENT | RGF_EXPLICITANGLE | RGF_FULLBRIGHT, 0, "PrismImpactOrange",
				atan(sin(CountInv("PrismSpin") + 225.0) * CountInv("PrismRadius") / 70),
				atan(cos(CountInv("PrismSpin") + 225.0) * CountInv("PrismRadius") / 70), 0, 2, 48.0,
				0,"PrismBeamOrange",-5);
			A_RailAttack(CountInv("PrismPower") * 0.2, -5, false, "", "8000FF", RGF_SILENT | RGF_EXPLICITANGLE | RGF_FULLBRIGHT, 0, "PrismImpactRed",
				atan(sin(CountInv("PrismSpin") + 270.0) * CountInv("PrismRadius") / 70),
				atan(cos(CountInv("PrismSpin") + 270.0) * CountInv("PrismRadius") / 70), 0, 2, 48.0,
				0,"PrismBeamRed",-5);
			A_RailAttack(CountInv("PrismPower") * 0.2, -5, false, "", "FF00FF", RGF_SILENT | RGF_EXPLICITANGLE | RGF_FULLBRIGHT, 0, "PrismImpactPurple",
				atan(sin(CountInv("PrismSpin") + 315.0) * CountInv("PrismRadius") / 70),
				atan(cos(CountInv("PrismSpin") + 315.0) * CountInv("PrismRadius") / 70), 0, 2, 48.0,
				0,"PrismBeamPurple",-5);
		} */
	  //For GLDEF lightshows. Too bad they lagged too hard to be actually used.
	  /*"####" "#" 0 A_RailAttack(0, -7, false, "none", "none", RGF_SILENT | RGF_EXPLICITANGLE, 12.5, "PrismBloodless",
				  atan(sin(CountInv("PrismSpin") + 0.0) * CountInv("PrismRadius") / 70),
				  atan(cos(CountInv("PrismSpin") + 0.0) * CountInv("PrismRadius") / 70), 0, 2, 64.0,
				  0,"PrismLightBlue",-1)
	  "####" "#" 0 A_RailAttack(0, -7, false, "none", "none", RGF_SILENT | RGF_EXPLICITANGLE, 12.5, "PrismBloodless",
				  atan(sin(CountInv("PrismSpin") + 45.0) * CountInv("PrismRadius") / 70),
				  atan(cos(CountInv("PrismSpin") + 45.0) * CountInv("PrismRadius") / 70), 0, 2, 64.0,
				  0,"PrismLightCyan",-1)
	  "####" "#" 0 A_RailAttack(0, -7, false, "none", "none", RGF_SILENT | RGF_EXPLICITANGLE, 12.5, "PrismBloodless",
				  atan(sin(CountInv("PrismSpin") + 90.0) * CountInv("PrismRadius") / 70),
				  atan(cos(CountInv("PrismSpin") + 90.0) * CountInv("PrismRadius") / 70), 0, 2, 64.0,
				  0,"PrismLightGreen",-1)
	  "####" "#" 0 A_RailAttack(0, -7, false, "none", "none", RGF_SILENT | RGF_EXPLICITANGLE, 12.5, "PrismBloodless",
				  atan(sin(CountInv("PrismSpin") + 135.0) * CountInv("PrismRadius") / 70),
				  atan(cos(CountInv("PrismSpin") + 135.0) * CountInv("PrismRadius") / 70), 0, 2, 64.0,
				  0,"PrismLightLime",-1)
	  "####" "#" 0 A_RailAttack(0, -7, false, "none", "none", RGF_SILENT | RGF_EXPLICITANGLE, 12.5, "PrismBloodless",
				  atan(sin(CountInv("PrismSpin") + 180.0) * CountInv("PrismRadius") / 70),
				  atan(cos(CountInv("PrismSpin") + 180.0) * CountInv("PrismRadius") / 70), 0, 2, 64.0,
				  0,"PrismLightYellow",-1)
	  "####" "#" 0 A_RailAttack(0, -7, false, "none", "none", RGF_SILENT | RGF_EXPLICITANGLE, 12.5, "PrismBloodless",
				  atan(sin(CountInv("PrismSpin") + 225.0) * CountInv("PrismRadius") / 70),
				  atan(cos(CountInv("PrismSpin") + 225.0) * CountInv("PrismRadius") / 70), 0, 2, 64.0,
				  0,"PrismLightOrange",-1)
	  "####" "#" 0 A_RailAttack(0, -7, false, "none", "none", RGF_SILENT | RGF_EXPLICITANGLE, 12.5, "PrismBloodless",
				  atan(sin(CountInv("PrismSpin") + 270.0) * CountInv("PrismRadius") / 70),
				  atan(cos(CountInv("PrismSpin") + 270.0) * CountInv("PrismRadius") / 70), 0, 2, 64.0,
				  0,"PrismBeamRed",-1)
	  "####" "#" 0 A_RailAttack(0, -7, false, "none", "none", RGF_SILENT | RGF_EXPLICITANGLE, 12.5, "PrismBloodless",
				  atan(sin(CountInv("PrismSpin") + 315.0) * CountInv("PrismRadius") / 70),
				  atan(cos(CountInv("PrismSpin") + 315.0) * CountInv("PrismRadius") / 70), 0, 2, 64.0,
				  0,"PrismLightPurple",-1)*/
		
		// "####" "#" 0 A_Jump(32,"BlueScreen","CyanScreen","GreenScreen","LimeScreen",
						// "YellowScreen","OrangeScreen","RedScreen","PurpleScreen");
		Goto PrismContinue;
	BlueScreen:
		"####" "#" 0 A_SetBlend("Blue",0.1,70,"White");
		Goto  PrismContinue;
	CyanScreen:
		"####" "#" 0 A_SetBlend("Cyan",0.1,70,"White");
		Goto  PrismContinue;
	GreenScreen:
		"####" "#" 0 A_SetBlend("Green",0.1,70,"White");
		Goto  PrismContinue;
	LimeScreen:
		"####" "#" 0 A_SetBlend("99 FF 00",0.1,70,"White");
		Goto  PrismContinue;
	YellowScreen:
		"####" "#" 0 A_SetBlend("Yellow",0.1,70,"White");
		Goto  PrismContinue;
	OrangeScreen:
		"####" "#" 0 A_SetBlend("Orange",0.1,70,"White");
		Goto  PrismContinue;
	RedScreen:
		"####" "#" 0 A_SetBlend("Red",0.1,70,"White");
		Goto  PrismContinue;
	PurpleScreen:
		"####" "#" 0 A_SetBlend("Purple",0.1,70,"White");
		Goto  PrismContinue;
	PrismContinue:
		"####" "#" 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"PrismRealLoop");
		Goto PrismEnd;
	
	//SCOURGEBREATH
	BreathLoop:
		"####" "#" 0 A_JumpIfInventory("Mana",3,1);
		Goto CastLoopMain;
		"####" "#" 0 A_OverlayOffset(3,-2 + frandom(4.0,-4.0),74 + frandom(4.0,-4.0),WOF_INTERPOLATE);
		"####" "#" 0 A_JumpIf(CountInv("BreathLooplet"),2);
		"####" "#" 0 A_GiveInventory("BreathLooplet",8);
		"####" "#" 1 Bright {
			A_PlaySound("Breath/Loop",5,0.7,1);
			A_AlertMonsters();
			A_TakeInventory("BreathLooplet",1);
			A_SetBlend("Red",0.1,15,"Black");
			if(CountInv("PowerDeadmaker")) { A_FireProjectile("SuperBreathProjectile",0,0,0,-8); }
			else 						   { A_FireProjectile("BreathProjectile",0,0,0,-8); }
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.9); } 
			if(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",random(2,3),TIF_NOTAKEINFINITE);
				A_SetPitch(pitch-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
				A_SetAngle(angle-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			}
			else
			{
				A_TakeInventory("Mana",random(1,2),TIF_NOTAKEINFINITE);
			}
		}
		"####" "#" 0 A_JumpIfInventory("BreathLooplet",1,"BreathLoop");
		"####" "#" 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"BreathLoop");
		"####" "#" 0 A_TakeInventory("BreathLooplet",8);
		Goto CastLoopMain;
	
	//SHEEPSHIELD
	SheepshieldLoop:
		"####" "#" 1 Bright {
			A_OverlayOffset(3,-2,74,WOF_INTERPOLATE);
			A_PlaySound("Sheepshield/Loop",6,0.7,1);
			A_AlertMonsters();
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); }
			if(!CountInv("PowerTomeEffect"))
			{
				A_FireProjectile("SheepCircleSpawner",0,0);
				A_SetBlend("White",0.05,25);
				A_TakeInventory("Mana",random(2,3),TIF_NOTAKEINFINITE);
			}
			else
			{
				A_FireProjectile("SuperSheepCircleSpawner1",0,0);
				A_FireProjectile("SuperSheepCircleSpawner2",0,0);
				A_FireProjectile("SuperSheepCircleSpawner3",0,0);
				A_SetBlend("Red",0.05,25);
				A_TakeInventory("Mana",2,TIF_NOTAKEINFINITE);
			}
		}
		"####" "#" 1 Bright A_OverlayOffset(3,0,72,WOF_INTERPOLATE);
		"####" "#" 1 Bright A_OverlayOffset(3,2,70,WOF_INTERPOLATE);
		"####" "#" 1 Bright { A_OverlayOffset(3,4,68,WOF_INTERPOLATE); A_TakeInventory("Mana",random(2,3),TIF_NOTAKEINFINITE); }
		"####" "#" 1 Bright A_OverlayOffset(3,2,70,WOF_INTERPOLATE);
		"####" "#" 1 Bright A_OverlayOffset(3,0,72,WOF_INTERPOLATE);
		"####" "#" 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"SheepshieldLoopCheck");
		Goto SheepshieldEnd;
	SheepshieldLoopCheck:
		"####" "#" 0 A_JumpIfInventory("Mana",4,"SheepshieldLoop");
	SheepshieldEnd:
		"####" "#" 0 {
			A_PlaySound("Sheepshield/Stop",6,0.7);
			A_TakeInventory("SheepActive",1);
			if(CountInv("PowerTomeEffect"))
			{
				A_SetBlend("Red",0.1,35);
				A_PlaySound("SuperSheep/Release",5,0.8);
			}
		}
		Goto CastLoopMain+5;
	
	//SIGIL
	SigilLoop:
		"####" "#" 0 {
			A_AlertMonsters();
			A_PlaySound("Sigil/Use",5,0.8);
			A_PlaySound("Sigil/Add",6,0.8);
			If(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",70,TIF_NOTAKEINFINITE);
				A_SetBlend("028dff",0.1,12);
				A_FireProjectile("SigilBomb",0,0,-12,0);
			}
			Else
			{
				A_TakeInventory("Mana",60,TIF_NOTAKEINFINITE);
				A_SetBlend("028dff",0.1,18);
				A_FireProjectile("SigilBomb",0,0,-12,0);
			}
			Return ResolveState("CastLoopMain");
		}
	
	//////////////////
	//CAST LOOP MAIN//
	//////////////////
	
	
	CastLoopMain:
		"####" "#" 1 Bright {
			A_OverlayOffset(3,-2,74,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.9); }
			A_SetPitch(pitch-2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 Bright {
			A_OverlayOffset(3,0,72,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.91); }
			A_SetPitch(pitch-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 Bright {
			A_OverlayOffset(3,2,70,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) {A_ZoomFactor(0.92); }
			A_SetPitch(Pitch-0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 Bright {
			A_OverlayOffset(3,4,68,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.93); }
			A_SetPitch(Pitch-0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			A_OverlayOffset(3,7,65,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.94); }
			A_SetPitch(pitch-0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			A_OverlayOffset(3,8,64,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.95); }
			A_SetPitch(pitch+0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); }
			A_SetPitch(pitch+0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle+0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.97); }
			A_SetPitch(pitch+0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle+0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.98); }
			A_SetPitch(Pitch+0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle+0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.99); }
			A_SetPitch(pitch+0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle+0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.0); } }
		"####" "#" 0 {
			If(CountInv("SkullfireInProgress")) { Return ResolveState("SkullfireRelaunch"); }
			If(CountInv("FlamewaveInProgress")) { Return ResolveState("FlamewaveRelaunch"); }
			If(CountInv("FrostbiteInProgress")) { Return ResolveState("FrostbiteRelaunch"); }
			If(CountInv("SpiritcannonInProgress")) { Return ResolveState("SpiritcannonRelaunch"); }
			If(CountInv("HammersmiteInProgress")) { Return ResolveState("HammersmiteRelaunch"); }
			If(CountInv("GumpopInProgress")) { Return ResolveState("GumpopRelaunch"); }
			If(CountInv("SkypunchInProgress")) { Return ResolveState("SkypunchRelaunch"); }
			If(CountInv("ThunderInProgress")) { Return ResolveState("ThunderRelaunch"); }
			If(CountInv("CorpseInProgress")) { Return ResolveState("CorpseRelaunch"); }
			If(CountInv("ThreadInProgress")) { Return ResolveState("ThreadRelaunch"); }
			If(CountInv("AnnihilationInProgress")) { Return ResolveState("AnnihilationRelaunch"); }
			If(CountInv("ApocalypseInProgress")) { Return ResolveState("ApocalypseRelaunch"); }
			If(CountInv("DarkpathInProgress")) { Return ResolveState("DarkpathRelaunch"); }
			If(CountInv("CrowsInProgress")) { Return ResolveState("CrowsRelaunch"); }
			If(CountInv("BreathInProgress")) { Return ResolveState("BreathRelaunch"); }
			If(CountInv("SheepshieldInProgress")) { Return ResolveState("SheepshieldRelaunch"); }
			If(CountInv("SigilInProgress")) { Return ResolveState("SigilRelaunch"); }
			Return ResolveState(Null);
		}
		Goto CastEnd;
	  
	  
	/////////////////
	//CAST RELAUNCH//
	/////////////////
	
	
	//SKULLFIRE
	SkullfireRelaunch:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "SkullfireRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 20, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"SkullfireLoop2");
		Goto CastEnd;
	SkullfireLoop2:
		"####" "#" 10;
		Goto SkullfireLoop;
	SkullfireRelaunchT:
		"####" "#" 1 A_JumpIf(CountInv("Mana") >= 30, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"SkullfireLoopT2");
		Goto CastEnd;
	SkullfireLoopT2:
		"####" "#" 15;
		Goto SkullfireLoop;

	//FLAEMWAVE
	FlamewaveRelaunch:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "FlamewaveRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 70, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"FlamewaveLoop2");
		Goto CastEnd;
	FlamewaveLoop2:
		"####" "#" 15;
		Goto FlamewaveLoop;
	FlamewaveRelaunchT:
		"####" "#" 1 A_JumpIf(CountInv("Mana") >= 100, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"FlamewaveLoopT2");
		Goto CastEnd;
	FlamewaveLoopT2:
		"####" "#" 25;
		Goto FlamewaveLoop;
		
	//FROSTBITE
	FrostbiteRelaunch:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "FrostbiteRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 30, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"FrostbiteLoop2");
		Goto CastEnd;
	FrostbiteLoop2:
		"####" "#" 20;
		Goto FrostbiteLoop;
	FrostbiteRelaunchT:
		"####" "#" 5 A_JumpIf(CountInv("Mana") >= 70, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"FrostbiteLoopT2");
		Goto CastEnd;
	FrostbiteLoopT2:
		"####" "#" 30;
		Goto FrostbiteLoop;
		
	//SPIRITCANNON
	SpiritcannonRelaunch:
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 20, 1);
		Goto CastEnd;
		"####" "#" 10 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"SpiritcannonLoop2");
		Goto CastEnd;
	SpiritcannonLoop2:
		"####" "#" 20;
		Goto SpiritcannonLoop;
		
	//HAHMMERSMITE
	HammersmiteRelaunch:
		"####" "#" 34;
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "HammersmiteRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 60, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"HammersmiteLoop2");
		Goto CastEnd;
	HammersmiteLoop2:
		"####" "#" 10;
		Goto HammersmiteLoop;
	HammersmiteRelaunchT:
		"####" "#" 1 A_JumpIf(CountInv("Mana") >= 90, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"HammersmiteLoop2");
		Goto CastEnd;
	
	//GUMPOP
	GumpopRelaunch:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "GumpopRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 10, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"GumpopLoop2");
		Goto CastEnd;
	GumpopLoop2:
		"####" "#" 10;
		Goto GumpopLoop;
	GumpopRelaunchT:
		"####" "#" 1 A_JumpIf(CountInv("Mana") >= 50, 1);
		Goto CastEnd;
		"####" "#" 10 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"GumpopLoopT2");
		Goto CastEnd;
	GumpopLoopT2:
		"####" "#" 15;
		Goto GumpopLoop;
		
	//SKYPUNCH
	SkypunchRelaunch:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "SkypunchRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 40, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"SkypunchLoop2");
		Goto CastEnd;
	SkypunchLoop2:
		"####" "#" 25;
		Goto SkypunchLoop;
	SkypunchRelaunchT:
		"####" "#" 1 A_JumpIf(CountInv("Mana") >= 60, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"SkypunchLoop2");
		Goto CastEnd;
	
	//THUNDERSTRUCK
	ThunderRelaunch:
		"####" "#" 3 A_TakeInventory("StormTrigger");
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "ThunderRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 30, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"ThunderLoop2");
		Goto CastEnd;
	ThunderLoop2:
		"####" "#" 25;
		Goto ThunderLoop;
	ThunderRelaunchT:
		"####" "#" 1 A_JumpIf(CountInv("Mana") >= 40, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"ThunderLoop2");
		Goto CastEnd;
		
	//CORPSEBLAST
	CorpseRelaunch:
		"####" "#" 4;
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "CorpseRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 25, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"CorpseLoop2");
		Goto CastEnd;
	CorpseLoop2:
		"####" "#" 20;
		Goto CorpseLoop;
	CorpseRelaunchT:
		"####" "#" 1 A_JumpIf(CountInv("Mana") >= 70, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"CorpseLoop2");
		Goto CastEnd;
	
	//THREADCUTTER
	ThreadRelaunch:
		"####" "#" 9;
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "ThreadRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 25, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"ThreadLoop2");
		Goto CastEnd;
	ThreadLoop2:
		"####" "#" 5;
		Goto ThreadLoop;
	ThreadRelaunchT:
		"####" "#" 1 A_JumpIf(CountInv("Mana") >= 60, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"ThreadLoop2T");
		Goto CastEnd;
	ThreadLoop2T:
		"####" "#" 35;
		Goto ThreadLoop;
		
	//ANNIHILATION
	AnnihilationRelaunch:
		"####" "#" 24;
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "AnnihilationRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 100, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"AnnihilationLoop2");
		Goto CastEnd;
	AnnihilationLoop2:
		"####" "#" 15;
		Goto AnnihilationLoop;
	AnnihilationRelaunchT:
		"####" "#" 10;
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 200, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"AnnihilationLoop2T");
		Goto CastEnd;
	AnnihilationLoop2T:
		"####" "#" 25;
		Goto AnnihilationLoop;
		
	//APOCALYPSE
	ApocalypseRelaunch:
		"####" "#" 26;
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "ApocalypseRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 100, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"ApocalypseLoop2");
		Goto CastEnd;
	ApocalypseLoop2:
		"####" "#" 15;
		Goto ApocalypseLoop;
	ApocalypseRelaunchT:
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 200, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"ApocalypseLoop2");
		Goto CastEnd;
		
	//DARKPATH
	DarkpathRelaunch:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "DarkpathRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 25, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"DarkpathLoop2");
		Goto CastEnd;
	DarkpathLoop2:
		"####" "#" 15;
		Goto DarkpathLoop;
	DarkpathRelaunchT:
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 45, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"DarkpathLoop2");
		Goto CastEnd;
	
	//HITCHCOCK'S BIRDS
	CrowsRelaunch:
		"####" "#" 19;
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "CrowsRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 25, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"CrowsLoop2");
		Goto CastEnd;
	CrowsLoop2:
		"####" "#" 15;
		Goto CrowsLoop;
	CrowsRelaunchT:
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 50, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"CrowsLoop2");
		Goto CastEnd;
		
	//SCOURGEBREATH
	BreathRelaunch:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "BreathRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 24, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"BreathLoop2");
		Goto CastEnd;
	BreathLoop2:
		"####" "#" 0 A_GiveInventory("BreathLooplet",8);
		Goto BreathLoop;
	BreathRelaunchT:
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 16, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"BreathLoop2");
		Goto CastEnd;

	
	//SHEEPSHIELD
	SheepshieldRelaunch:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "SheepshieldRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 25, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"SheepshieldLoop2");
		Goto CastEnd;
	SheepshieldLoop2:
		"####" "#" 10;
		Goto SheepshieldInit;
	SheepshieldRelaunchT:
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 100, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"SheepshieldLoop2");
		Goto CastEnd;
	
	//SIGIL
	SigilRelaunch:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"), "SigilRelaunchT");
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 70, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"SigilLoop2");
		Goto CastEnd;
	SigilLoop2:
		"####" "#" 35;
		Goto SigilLoop;
	SigilRelaunchT:
		"####" "#" 10 A_JumpIf(CountInv("Mana") >= 60, 1);
		Goto CastEnd;
		"####" "#" 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"SigilLoopT2");
		Goto CastEnd;
	SigilLoopT2:
		"####" "#" 35;
		Goto SigilLoop;
	
	///////////
	//CAST END//
	////////////
	
	//PRISM LAZER
    PrismEnd:
		"####" "#" 0 {
			A_PlaySound("Prism/End",6);
			A_StopSound(1);
			A_TakeInventory("PrismRadius",999);
			A_TakeInventory("PrismSpin",999);
			A_TakeInventory("PrismPower",999);
			
			if(Invoker.Prism) {
				Invoker.Prism.End();
			}
			
			Gc_PrismRaveHandler.EndLocalRave(invoker.PlayerNumber());
		}
		"####" "#" 1 Bright { A_OverlayOffset(3,0,72,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.91); } }
		"####" "#" 1 Bright { A_OverlayOffset(3,2,70,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.92); } }
		"####" "#" 1 Bright { A_OverlayOffset(3,4,68,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.93); } }
		"####" "#" 1 {		  A_OverlayOffset(3,7,65,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.94); } }
		"####" "#" 1 {		  A_OverlayOffset(3,8,64,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.95); } }
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); } }
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.97); } }
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.98); } }
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.99); } }
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.0); } }
		Goto CastEnd;
	
	BreathEnd:
		"####" "#" 0 A_PlaySound("Breath/End",5,0.8);
		Goto CastEnd;
		
	CastEnd:
		"####" "#" 0 {
			A_TakeInventory("SkullfireInProgress",1);
			A_TakeInventory("FlamewaveInProgress",1);
			A_TakeInventory("FrostbiteInProgress",1);
			A_TakeInventory("SpiritcannonInProgress",1);
			A_TakeInventory("HammersmiteInProgress",1);
			A_TakeInventory("GumpopInProgress",1);
			A_TakeInventory("SkypunchInProgress",1);
			A_TakeInventory("CorpseInProgress",1);
			A_TakeInventory("ThunderInProgress",1);
			if(CountInv("ThreadInProgress")) { A_StopSound(5); A_TakeInventory("ThreadInProgress",1); A_TakeInventory("PowerZaWarudo",1); }
			A_TakeInventory("AnnihilationInProgress");
			A_TakeInventory("ApocalypseInProgress",1);
			A_TakeInventory("DarkpathInProgress",1);
			A_TakeInventory("CrowsInProgress",1);
			A_TakeInventory("PrismInProgress",1);
			if(CountInv("BreathInProgress")) { A_PlaySound("Breath/End",5,0.8); A_TakeInventory("BreathInProgress",1); }
			A_TakeInventory("SheepshieldInProgress",1);
			A_TakeInventory("ChillgraspInProgress",1);
		}

		"####" "#" 1 A_OverlayOffset(3,10,67,WOF_INTERPOLATE);
		"####" "#" 1 A_OverlayOffset(3,12,79,WOF_INTERPOLATE);
		"####" "#" 1 A_OverlayOffset(3,18,98,WOF_INTERPOLATE);
		"####" "#" 1 A_OverlayOffset(3,21,118,WOF_INTERPOLATE);
		"####" "#" 1 A_OverlayOffset(3,19,142,WOF_INTERPOLATE);
		"####" "#" 1 A_OverlayOffset(3,17,165,WOF_INTERPOLATE);
		"####" "#" 1 A_OverlayOffset(3,9,182,WOF_INTERPOLATE);
		"####" "#" 1 A_OverlayOffset(3,2,190,WOF_INTERPOLATE);
		"####" "#" 0 {
			invoker.weapAction--;
			invoker.LeftHand = 0;
			if(invoker.HandCast) {
				invoker.HandCast = 0;
				Return ResolveState("CastHandEnd");
			}
			if(invoker.StratCast) {
				invoker.StratCast = 0;
				Return ResolveState("CastStratEnd");
			}
			Return ResolveState("LeftActive");
		}
		Goto LeftActive;

	ChillgraspLoop:
		"####" "#" 0 {
			A_PlaySound("Chillgrasp/Loop",5,1.0,1);
			A_SetBlend("Purple",0.1,20);
		}
	ChillgraspLoop2:
		"####" "#" 1 {
			A_SetBlend("Purple",0.05,20);
			A_AlertMonsters();
			A_TakeInventory("Mana",1,TIF_NOTAKEINFINITE);
		}
		"####" "#" 0 {
			let grasp = Guncaster(player.mo).grasp;
			Actor scanned = grasp.ScanForTargets(300.0);
			
			if(	scanned &&
				!grasp.IsGrasped(scanned) &&
				!grasp.IsGrasping(scanned)) {
				grasp.BeginHold(scanned);
				
				Return ResolveState("ChillgraspStart");
				/*let state = player.readyweapon.FindState("ChillgraspStart");
				player.SetPsprite(PSP_WEAPON, state);*/
			}
			
			else {
				Return A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK && CountInv("Mana") > 25, "ChillgraspLoop2");
			}
			Return ResolveState(null);
		}
		Goto ChillgraspEnd;
	ChillgraspStart:
		"####" "#" 0 A_PlaySound("Chillgrasp/Loop",5,1.0,1);
		"####" "#" 0 A_PlaySound("Chillgrasp/Launch",6);
		"####" "#" 0 A_TakeInventory("Mana",25,TIF_NOTAKEINFINITE);
		"####" "#" 0 A_SetBlend("Purple",0.1,20);
		"####" "#" 1 Bright {
			A_OverlayOffset(3,-2,74,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.9); }
			A_SetPitch(pitch-2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 Bright {
			A_OverlayOffset(3,0,74,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.91); }
			A_SetPitch(pitch-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 Bright {
			A_OverlayOffset(3,2,70,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) {A_ZoomFactor(0.92); }
			A_SetPitch(Pitch-0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 Bright {
			A_OverlayOffset(3,4,68,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.93); }
			A_SetPitch(Pitch-0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			A_OverlayOffset(3,7,65,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.94); }
			A_SetPitch(pitch-0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			A_OverlayOffset(3,8,64,WOF_INTERPOLATE);
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.95); }
			A_SetPitch(pitch+0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle-0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); }
			A_SetPitch(pitch+0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle+0.1 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.97); }
			A_SetPitch(pitch+0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle+0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.98); }
			A_SetPitch(Pitch+0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle+0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 1 {
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.99); }
			A_SetPitch(pitch+0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
			A_SetAngle(angle+0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
	ChillgraspLoopMain:
		"####" "#" 0 {
			A_PlaySound("Chillgrasp/Loop",5,1.0,1);
			A_SetBlend("Purple",0.1,20);
		}
	ChillgraspLoopMain2:
		"####" "#" 1 A_TakeInventory("Mana",1,TIF_NOTAKEINFINITE);
		"####" "#" 0 {
			A_AlertMonsters();
			A_SetBlend("Purple",0.05,20);
			let me = Guncaster(player.mo);
			if(me.grasp.IsHolding() && CountInv("Mana")) {
				Return A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK,"ChillgraspLoopMain2");
			}
			Return ResolveState(null);
		}
		Goto ChillgraspEnd;
	ChillgraspEnd:
		"####" "#" 0 {
			let me = Guncaster(player.mo);
			A_PlaySound("Chillgrasp/End",5);
			me.grasp.EndHold();
		}
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); } }
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.97); } }
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.98); } }
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.99); } }
		"####" "#" 1 { if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.0); } }
		Goto CastEnd;
	  
	//FIREBREATH
	FirebreathLaunch:
		"####" "#" 0 {
			if(CountInv("PowerDeadmaker"))
			{
				if(CountInv("Mana") >= 100) { Return ResolveState("DeadmakerBreath"); }
				else { invoker.HandCast = 0; Return ResolveState("LeftActive"); }
			}
			if(CountInv("PowerTomeEffect"))
			{
				Return ResolveState("FirebreathLaunchT");
			}
			if(CountInv("PowerSuitToken") && CountInv("Mana") >= 10)
			{
				A_TakeInventory("Mana",10,TIF_NOTAKEINFINITE);
				Return ResolveState(null);
			}
			else if(CountInv("Mana") >= 20)
			{
				A_TakeInventory("Mana",20,TIF_NOTAKEINFINITE);
				Return ResolveState(null);
			}
			else
			{
				invoker.HandCast = 0;
				Return ResolveState("LeftActive");
			}
			Return ResolveState(null);
		}
		"####" "#" 0 {
			A_PlaySound("TNT/Ignition",1,0.9);
			invoker.WeapAction++;
		}
		"####" "#" 1 A_SetPitch(Pitch - 0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch - 0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch - 0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(pitch - 1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(pitch - 2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "###" 1 A_SetPitch(pitch - 2.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					A_FireProjectile("BlueTiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
				else
				{
					A_FireProjectile("TiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
			}
			else
			{
					A_FireProjectile("IgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("IgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
			}
			 A_SetPitch(Pitch + 6.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					A_FireProjectile("BlueTiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
				else
				{
					A_FireProjectile("TiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
			}
			else
			{
					A_FireProjectile("IgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("IgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
			}
			 A_SetPitch(Pitch + 5.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					A_FireProjectile("BlueTiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
				else
				{
					A_FireProjectile("TiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
			}
			else
			{
					A_FireProjectile("IgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("IgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
			}
			 A_SetPitch(Pitch + 3.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					A_FireProjectile("BlueTiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
				else
				{
					A_FireProjectile("TiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
			}
			else
			{
					A_FireProjectile("IgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("IgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
			}
			 A_SetPitch(Pitch + 2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					A_FireProjectile("BlueTiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
				else
				{
					A_FireProjectile("TiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
			}
			else
			{
					A_FireProjectile("IgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("IgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
			}
			 A_SetPitch(Pitch + 1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					A_FireProjectile("BlueTiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
				else
				{
					A_FireProjectile("TiberianIgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
				}
			}
			else
			{
					A_FireProjectile("IgnitionSnort",frandom(2.0,-2.0),0,0,0,0,frandom(2.0,-2.0));
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("IgnitionSmoke",frandom(2.0,-2.0),0,0,0,0,frandom(4.0,-4.0));
					}
			}
			 A_SetPitch(Pitch + 0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 25 { invoker.weapAction--; invoker.LeftHand = 0; invoker.HandCast = 0; }
		"####" "#" 0 A_Jump(256,"LeftActive");
		Goto LeftActive;
		
	FirebreathLaunchT:
		"####" "#" 0 {
			if(CountInv("PowerSuitToken") && CountInv("Mana") >= 25)
			{
				A_TakeInventory("Mana",25,TIF_NOTAKEINFINITE);
				Return ResolveState(null);
			}
			else if(CountInv("Mana") >= 50)
			{
				A_TakeInventory("Mana",50,TIF_NOTAKEINFINITE);
				Return ResolveState(null);
			}
			else
			{
				invoker.HandCast = 0;
				Return ResolveState("LeftActive");
			}
			Return ResolveState(null);
		}
		"####" "#" 0 {
			invoker.WeapAction++;
			A_PlaySound("TNT/Ignition",1,0.9);
		}
		"####" "#" 1 A_SetPitch(Pitch - 0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch - 0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch - 0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(pitch - 1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(pitch - 2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "###" 1 A_SetPitch(pitch - 2.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		
		//AAAAAAAAAAAAAAAAAAAAAGGGGGGGGGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH~
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
				else
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
			}
			else
			{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
			}
			 A_SetPitch(Pitch + 6.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
				else
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
			}
			else
			{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
			}
			 A_SetPitch(Pitch + 5.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
				else
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
			}
			else
			{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
			}
			 A_SetPitch(Pitch + 3.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
				else
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
			}
			else
			{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
			}
			 A_SetPitch(Pitch + 2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
				else
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
			}
			else
			{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
			}
			 A_SetPitch(Pitch + 1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		
		"####" "#" 1 {
			if(CountInv("PowerSuitToken"))
			{
				if(CountInv("TibCore"))
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("BlueTiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
				else
				{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("TiberianIgnitionSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
				}
			}
			else
			{
					for(invoker.Loopler = 0; invoker.Loopler <= 3; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSnort",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
					for(invoker.Loopler = 0; invoker.Loopler <= 5; invoker.Loopler++)
					{
						A_FireProjectile("FiresweepSmoke",frandom(32.0,-32.0),0,0,0,0,frandom(0.5,-0.5));
					}
			}
			 A_SetPitch(Pitch + 0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		}
		"####" "#" 25 { invoker.weapAction--; invoker.LeftHand = 0; invoker.HandCast = 0; }
		"####" "#" 0 A_Jump(256,"LeftActive");
		Goto LeftActive;
	DeadmakerBreath:
		"####" "#" 0 {
			invoker.LoopLeft = 100;
			//A_TakeInventory("Mana",CountInv("PowerTomeEffect") ? 25 : 50,TIF_NOTAKEINFINITE);
			A_QuakeEx(3,3,3,123,0,512,"none");
			A_SpawnItemEx("DeadmakerBreathSounder",0,0,0,0,0,0,0,SXF_SETMASTER); //Not enough soundslots for this one, hun!
			/*int randomese;
			randomese = random(0,3);
			switch(randomese)
			{
				default:
				case 1:
					A_PlaySound("Deadmaker/Firebreath1",5);
					A_PlaySound("Deadmaker/Firebreath1",6);
					break;
				case 2:
					A_PlaySound("Deadmaker/Firebreath2",5);
					A_PlaySound("Deadmaker/Firebreath2",6);
					break;
				case 3:
					A_PlaySound("Deadmaker/Firebreath3",5);
					A_PlaySound("Deadmaker/Firebreath3",6);
					break;
				case 4:
					A_PlaySound("Deadmaker/Firebreath4",5);
					A_PlaySound("Deadmaker/Firebreath4",6);
					break;
			}*/
		}
	DeadmakerBreathMain:
		"####" "#" 1 { 
			A_SetAngle(Angle + frandom(1.5,-1.5),SPF_INTERPOLATE);
			A_SetPitch(Pitch + frandom(1.5,-1.5),SPF_INTERPOLATE);
			A_WeaponOffset(0+frandom(5.0,-5.0),32+frandom(5.0,0.0),WOF_INTERPOLATE);
			A_SetBlend("Orange",frandom(0.2,0.22),35);
			if(CountInv("PowerTomeEffect") && random(0,1) == 0) {
				A_TakeInventory("Mana",1,TIF_NOTAKEINFINITE);
			}
			if(!CountInv("PowerTomeEffect")) {
				A_TakeInventory("Mana",1,TIF_NOTAKEINFINITE);
			}
			for(int Enas = 0; Enas <= 3; Enas++)
			{
				A_FireProjectile("SuperIgnitionSnort",frandom(7.0,-7.0),0,0,0,0,frandom(4.0,-4.0));
			}
			for(int Enas = 0; Enas <= 2; Enas++)
			{
				A_FireProjectile("SuperIgnitionSmoke",frandom(7.0,-7.0),0,0,0,0,frandom(4.0,-4.0));
			}
			A_FireProjectile("SuperIgnitionParticle",frandom(7.0,-7.0),0,0,0,0,frandom(4.0,-4.0));
			invoker.LoopLeft--;
		}
		"####" "#" 0 A_JumpIf(invoker.LoopLeft > 0, "DeadmakerBreathMain");
		"####" "#" 25 {
			A_WeaponOffset(0,32,WOF_INTERPOLATE);
			A_QuakeEx(3,3,3,15,0,512,"none",QF_SCALEDOWN);
		}
		"####" "#" 0 { invoker.weapAction--; invoker.LeftHand = 0; invoker.HandCast = 0; }
		"####" "#" 0 A_Jump(256,"LeftActive");
		Goto LeftActive;
		
	//DRAGONSHOUT
	DragonshoutLaunch:
		"####" "#" 0 {
			if(CountInv("PowerTomeEffect") && CountInv("Mana") >= 75)
			{
				A_TakeInventory("Mana",75,TIF_NOTAKEINFINITE);
				Return ResolveState(null);
			}
			else if(CountInv("Mana") >= 100)
			{
				A_TakeInventory("Mana",100,TIF_NOTAKEINFINITE);
				Return ResolveState(null);
			}
			else
			{
				Return ResolveState("FlushTriggers");
			}
		}
		"####" "#" 0 {
				invoker.WeapAction++;
					If(random(1,100) <= GetCvar("GC_ShoutChance")) {
				A_PlaySound("Guncaster/Shout",2,1.0);
			}
		}
		"####" "#" 5 A_SpawnItemEx("Dragonshouter",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION|SXF_ORIGINATOR|SXF_SETTARGET);
		"####" "#" 1 A_SetPitch(Pitch-0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch-0.25 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch-0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(pitch-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(pitch-2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "###" 1 A_SetPitch(pitch-2.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 4;
		"####" "#" 1 A_SetPitch(Pitch+0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch+2.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch+4.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch+5.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 0 A_AlertMonsters();
		"####" "#" 0 A_FireProjectile("Dragonshout",0,0);
		"####" "#" 0 A_SetBlend("c2fff3",0.2,35);
		"####" "#" 1 A_SetPitch(Pitch+6.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch+3.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "##" 1 A_SetPitch(pitch+1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch+0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		
		"####" "#" 1;
		
		"####" "#" 1 A_SetPitch(Pitch-6.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch-3.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "##" 1 A_SetPitch(pitch-1.0 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		"####" "#" 1 A_SetPitch(Pitch-0.5 * GetCvar("GC_WeaponRecoil"), SPF_INTERPOLATE);
		
		"####" "#" 29 A_JumpIf(CountInv("PowerTomeEffect"),1);
		"####" "#" 25 { invoker.weapAction--; invoker.LeftHand = 0; invoker.HandCast = 0; }
		"####" "#" 0 A_Jump(256,"LeftActive");
		Goto LeftActive;

	//METEORFIST
	
	MeteorfistLaunch:
		"####" "#" 0 {
			If(CountInv("PowerTomeEffect")) {
				If(CountInv("Mana") >= 150) { A_Overlay(-2,"none"); A_Overlay(-4,"none"); Return ResolveState("MeteorfistStart"); } //Shoddy fix for matriarch/strucker screwing up hand removal.
				Else { Return ResolveState("FlushTriggers"); }
			}
			Else If(CountInv("Mana") >= 100) { A_Overlay(-2,"none"); A_Overlay(-4,"none"); Return ResolveState("MeteorfistStart"); }
			Return ResolveState("FlushTriggers");
		}
	MeteorfistStart:
		C2DP B 0 A_JumpIf(CountInv("PowerDeadmaker") && CountInv("PowerSuitDraugh"),7);
		C2NP B 0 A_JumpIf(CountInv("PowerDeadmaker"),6);
		C2CP B 0 A_JumpIf(CountInv("PowerSuitToken"),5);
		C2UP B 0 A_JumpIf(CountInv("PowerSuitProtect"),4);
		C2YP B 0 A_JumpIf(CountInv("PowerSuitDraugh"),3);
		C2MP B 0 A_JumpIf(CountInv("PowerMidasMode"),2);
		C2GP B 0;
		"####" "#" 0 {
			A_OverlayFlags(OverlayID(),PSPF_FLIP|PSPF_MIRROR,1);
			invoker.WeapAction++;
			invoker.LeftHand = 1;
			if(random(1,3) == 1) { A_PlaySound("Guncaster/Kick",2); }
			A_PlaySound("Stomp/Use",0,1);
			A_PlaySound("SuperSheep/Whoosh",5,0.7,1);
		}
		"####" "#" 1 { A_OverlayOffset(OverlayID(),195,150); 				 if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.98); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),173,120,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.96); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),151,94,WOF_INTERPOLATE);  if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.94); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),132,73,WOF_INTERPOLATE);  if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.92); } }
		"####" "#" 1 { A_OverlayOffset(OverlayID(),127,68,WOF_INTERPOLATE);	 if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.9); } }
	MeteorfistLoop:
		"####" "#" 0 A_JumpIf(CountInv("PowerTomeEffect"),2);
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 75,2);
		Goto MeteorfistStop;
		"####" "#" 0 A_JumpIf(CountInv("Mana") >= 125,1);
		Goto MeteorfistStop;
		"####" "#" 1 {
			A_OverlayOffset(OverlayID(),127 + frandom(2.0,-2.0),68 + frandom(2.0,-2.0),WOF_INTERPOLATE);
			A_ChangeVelocity (Cos(Pitch) * 12.0, 0, Sin(Pitch) * -12.0, CVF_RELATIVE);
			A_SetBlend("Orange",0.1,15);
			bNogravity = 1;
			A_FireProjectile("MeteorfistCheck",0,0,0,8);
			A_TakeInventory("Mana",1,TIF_NOTAKEINFINITE);
		}
		"####" "#" 0 A_JumpIf(CountInv("MeteorfistConnected"),"MeteorfistHit");
		"####" "#" 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK, "MeteorfistLoop");
		Goto MeteorfistStop;
	MeteorfistStop:
		"####" "#" 0 {
			bNogravity = 0;
			A_StopSound(5);
			A_TakeInventory("Mana",25,TIF_NOTAKEINFINITE);
		}
		"####" C 1 { A_OverlayOffset(OverlayID(),124,68,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.91); } }
		"####" C 1 { A_OverlayOffset(OverlayID(),128,76,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.93); } }
		"####" C 1 { A_OverlayOffset(OverlayID(),138,90,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.95); } }
		"####" B 1 { A_OverlayOffset(OverlayID(),150,111,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.97); } }
		"####" B 1 { A_OverlayOffset(OverlayID(),164,135,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.98); } }
		"####" B 1 { A_OverlayOffset(OverlayID(),178,158,WOF_INTERPOLATE); if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(0.99); } }
		TNT1 A 5;
		"####" "#" 0 {
			if(GetCvar("GC_ZoomRecoil")) { A_ZoomFactor(1.0); }
			A_OverlayFlags(OverlayID(),PSPF_FLIP|PSPF_MIRROR,0);
			invoker.weapAction--;
			invoker.LeftHand = 0;
			if(invoker.HandCast) {
				invoker.HandCast = 0;
				Return ResolveState("CastHandEnd");
			}
			if(invoker.StratCast) {
				invoker.StratCast = 0;
				Return ResolveState("CastStratEnd");
			}
			Return ResolveState("LeftActive");
		}
		Goto LeftActive;
	MeteorfistHit:
		"####" A 1 {
			invoker.Loopler = random(7,9);
			A_StopSound(5);
			A_OverlayOffset(OverlayID(),123,66,WOF_INTERPOLATE);
			if(!CountInv("PowerTomeEffect"))
			{
				A_TakeInventory("Mana",100,TIF_NOTAKEINFINITE);
				A_FireProjectile("MeteorfistImpact",0,0);
				A_SetBlend("Orange",0.4,55);
			}
			else
			{
				A_TakeInventory("Mana",150,TIF_NOTAKEINFINITE);
				A_FireProjectile("SuperMeteorfistImpact",0,0);
				A_SetBlend("Orange",0.4,55);
			}
		}
	MeteorfistHitLoop:
		"####" A 1 {
			A_OverlayOffset(OverlayID(),127 + frandom(13.0,-13.0), 68 + frandom(10.0,-10.0),WOF_INTERPOLATE);
			invoker.Loopler--;
		}
		"####" A 0 A_JumpIf(invoker.Loopler, "MeteorfistHitLoop");
		"####" A 10 {
			A_OverlayOffset(OverlayID(),127,68,WOF_INTERPOLATE);
			A_TakeInventory("MeteorfistConnected");
		}
		Goto MeteorfistStop;
	}
}