actor JewelEncaserWep_NormalBar : NormalBar{args 4, 36}
actor JewelEncaserWep : BaseMM8BDMWep
{
Weapon.Ammouse 28
Weapon.AmmoGive 0
Weapon.SlotNumber 7
Obituary "$OB_JEWELENCASER"
Tag "$TAG_JEWELENCASER"
Inventory.Pickupmessage "$PU_JEWELENCASER"
weapon.ammotype "JewelEncaserAmmo"
inventory.icon "JENCICON"
States
{
SpawnLoop:
JENC Z 1
loop
Ready:
JNCH J 0 A_JumpIfInventory("EquippedJewelOnce",1,"Ready2")
JNCH J 0 A_GiveInventory("JewelEncaserAmmo",28)
JNCH J 0 A_GiveInventory("EquippedJewelOnce",1)
Ready2:
JNCH J 0 ACS_NamedExecuteWithResult("core_weaponcolor",COLOR_JEWELENCASER)
JNCH J 1 A_WeaponReady
Goto Ready2+1
ReadyC: Goto Ready2+1
Deselect:
JNCH J 0
goto DeselectSwap
Select:
JNCH K 0
goto SelectSwap
Fire:
JNCH J 0 A_JumpIfInventory("JewelEncaserTime",1,"NoAmmo")
JNCH J 0 A_JumpIfNoAmmo("NoAmmo")
JNCH K 2 A_GiveInventory("ShieldCheck",1)
JNCH K 0 A_TakeInventory("ShieldCheck",1)
JNCH J 0 A_TakeInventory("JewelEncaserAmmo",28)
JNCH A 0 A_GiveInventory("JewelEncasePower",1)
JNCH M 0 A_GiveInventory("JewelEncaserTime", 350)
JNCH M 0 A_PlaySoundEx("weapon/jewelsatellite", "Weapon")
JNCH M 0 A_SpawnItemEx("JewelEncaserShield",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
JNCH M 0 A_SpawnItemEx("JewelEncaserShield2",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
JNCH M 0 A_GiveInventory("JewelEncaserSpawner",1)
JNCH LMNOP 2
JNCH J 8
JNCH J 1 
goto Ready2+1
NoAmmo:
JNCH J 1 ACS_NamedExecute("core_noammo",0)
goto Ready2+1
}
}
actor EquippedJewelOnce : Once {}

actor JewelEncaserAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 28
+INVENTORY.IGNORESKILL
}

actor JewelEncaserTime : Inventory
{
inventory.amount 1
inventory.maxamount 350 //10 seconds.
}

actor JewelEncasePower : PowerProtection
{
Powerup.duration -10
damagefactor "Normal", 0.0
damagefactor "Crush", 1
damagefactor "Falling", 1
damagefactor "Fire", 1
damagefactor "Drowning", 1
damagefactor "Slime", 1
damagefactor "Ice", 1
damagefactor "Spiney", 1
}

actor JewelEncaserSpawner : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_SpawnItemEx("JewelEncaserWatcher")
stop
}
}

actor JewelEncaserWatcher
{
	+MISSILE
	+NOINTERACTION
	+DONTBLAST
	+NOGRAVITY
	-SOLID
	Height 1
	Radius 1
	var int user_countdown;
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 1 A_Warp(AAPTR_TARGET, 0, 0, 0, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
			TNT1 A 0 A_TakeFromTarget("JewelEncaserTime",1)
			TNT1 A 0 A_SetUserVar("user_countdown", user_countdown + 1)
			TNT1 A 0 A_JumpIfInTargetInventory("ShieldCheck", 1, "DeathSilent")
			TNT1 A 0 A_JumpIf(user_countdown >= 350, "DeathSilent")
			TNT1 A 0 A_JumpIfInTargetInventory("JewelEncaserTime", 1, "Spawn")
			Goto Death
		Death:
			TNT1 AA 0 A_Warp(AAPTR_TARGET, 0, 0, 0, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
			TNT1 A 0 A_PlaySoundEx("weapon/centaurflash","Weapon",0)
		DeathSilent:
			TNT1 A 0 A_TakeFromTarget("JewelEncaserTime", 999)
			TNT1 A 0 A_TakeFromTarget("JewelEncasePower", 1)
			TNT1 A 5
			stop
		End:
			TNT1 A 0
			TNT1 A 0 A_TakeFromTarget("JewelEncaserTime", 999)
			TNT1 A 0 A_TakeFromTarget("JewelEncasePower", 1)
			stop
	}
}


actor JewelEncaserShield : BasicShieldWarper
{
+BRIGHT
Scale 2.15
renderstyle "add"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_GiveInventory("MM8BDMProjSpawnFuncClient",1)
TNT1 A 1
TNT1 A 0 ACS_NamedExecuteAlways("core_shieldwarper_encaser", 0, "test")
TNT1 A 0 A_Jump(256, "Shield")
Goto Shield
Shield:
JWNC ABCDEFGHIJKLMNOP 1 A_Warp(AAPTR_TARGET, 0, 0, -4, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
loop
}
}

actor JewelEncaserShield2 : JewelEncaserShield 
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_GiveInventory("MM8BDMProjSpawnFuncClient",1)
TNT1 A 1
TNT1 A 0 ACS_NamedExecuteAlways("core_shieldwarper_encaser", 0, "test")
TNT1 A 0 A_Jump(256, "Shield")
Goto Shield
Shield:
JWNC IJKLMNOPABCDEFGH 1 A_Warp(AAPTR_TARGET, 0, 0, -4, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION) 
loop}
}
