actor EtherealCrossbow : Weapon
{
	obituary "%o was splattered by %k's Ethereal Crossbow."
	radius 20
	height 16
	inventory.pickupmessage "ETHEREAL CROSSBOW"
	weapon.selectionorder 1
	weapon.ammotype1 "Mana2"
	Weapon.KickBack 100
	weapon.ammouse1 3
	Weapon.AmmoGive1 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType2 "Mana2"
	Weapon.AmmoUse2 5
	Tag "Ethereal Crossbow"
	AttackSound "HunterEtherealCrossBowAltFire"
	+UNDROPPABLE
	Weapon.BobStyle InverseSmooth
	Weapon.BobSpeed 2.1
	Weapon.BobRangeY 0.4
	Weapon.BobRangeX 0.5
	states
	{
	Ready:
		CRB2 A 0 A_JumpIfInventory("IsMarksman",1,"ReadyZoom")
		CRB2 AAAABBBBCCCC 1 A_WeaponReady
		Loop
	ReadyZoom:
		CRB2 AAAABBBBCCCC 1 A_WeaponReady(WRF_ALLOWZOOM)
		loop
	Deselect:
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel2")
		TNT1 A 0 A_TakeInventory("PowerZoomLevel1")
		CRB2 A 1 A_Lower
		TNT1 A 0 A_Lower
		CRB2 B 1 A_Lower
		TNT1 A 0 A_Lower
		CRB2 C 1 A_Lower
		TNT1 A 0 A_Lower
		loop
	Select:
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel2")
		TNT1 A 0 A_TakeInventory("PowerZoomLevel1")
		CRB2 A 1 A_Raise
		TNT1 A 0 A_Raise
		CRB2 B 1 A_Raise
		TNT1 A 0 A_Raise
		CRB2 C 1 A_Raise
		TNT1 A 0 A_Raise
		loop
	Fire:
		CRB2 A 3 Offset(0, 50) A_GiveInventory("MarksmanFocusCheck", 1)
		//CRB2 D 0 A_PlaySound("HunterEtheralCrossBowFire")
		CRB2 D 0 A_PlayWeaponSound("HunterEtherealCrossBowFire")
		CRB2 D 0 A_FireCustomMissile("ECrossbowFX3", -4.5, 0, -2, 3)
		CRB2 D 0 A_FireCustomMissile("ECrossbowFX3", 4.5, 0, -2, 3)
		CRB2 D 1 Offset(0, 49) A_FireCustomMissile("ECrossbowFX1", 0, 1, 0, 3)
		CRB2 D 1 Offset(0, 47) A_SetPitch(Pitch-.6)
		CRB2 D 1 Offset(0, 46) A_SetPitch(Pitch+.2)
		CRB2 E 1 Offset(0, 45) A_SetPitch(Pitch+.2)
		CRB2 E 1 Offset(0, 44) A_SetPitch(Pitch+.2)
		CRB2 E 1 Offset(0, 43)
		CRB2 E 1 Offset(0, 42)
		CRB2 F 1 Offset(0, 40)
		CRB2 F 1 Offset(0, 39)
		CRB2 G 1 Offset(0, 36)
		CRB2 G 2 Offset(0, 35)
		CRB2 H 2 Offset(0, 34)
		CRB2 B 2 Offset(0, 33) A_ReFire
		CRB2 CC 2 Offset(0, 32)
		goto Ready
	AltFire:
		CRB2 A 3 Offset(0, 48) A_GiveInventory("MarksmanFocusCheck", 1)
		CRB2 D 0 A_FireBullets(0,0,1,0,"EtherealCrossbowPuff2",FBF_NORANDOM|FBF_NORANDOMPUFFZ)
		CRB2 D 0 A_RailAttack(ACS_NamedExecuteWithResult("WOC Player Scale", FRandom(100,120), AGILITY, ABIL_RANGEDMASTERY, ACTIVATOR), 0, 1, "Green", "Yellow", RGF_NOPIERCING, 0, "EtherealCrossbowPuff", 0, 0, 0, 0, 5, 1, "EtherealRail", 1)
		CRB2 D 1 Offset(0, 49) A_PlayWeaponSound("HunterEtherealCrossBowAltFire") 
		CRB2 D 1 Offset(0, 48) A_SetPitch(Pitch-1.2)
		CRB2 D 1 Offset(0, 47) A_SetPitch(Pitch+0.4)
		CRB2 D 1 Offset(0, 46) A_SetPitch(Pitch+0.4)
		CRB2 E 1 Offset(0, 45) A_SetPitch(Pitch+0.4)
		CRB2 E 1 Offset(0, 44)
		CRB2 E 1 Offset(0, 43)
		CRB2 E 1 Offset(0, 42)
		CRB2 E 1 Offset(0, 41)
		CRB2 F 1 Offset(0, 40)
		CRB2 F 1 Offset(0, 39)
		CRB2 F 1 Offset(0, 38)
		CRB2 F 1 Offset(0, 37)
		CRB2 G 1 Offset(0, 36)
		CRB2 G 2 Offset(0, 35)
		CRB2 H 2 Offset(0, 34)
		CRB2 B 2 Offset(0, 33) A_ReFire
		CRB2 CC 2 Offset(0, 32)
		Goto Ready
	Flash:
		CRB2 I 4 bright A_Light1
		CRB2 J 3 bright A_Light2
		CRB2 J 0 bright A_Light0
		stop
	Spawn:
		WBOW B -1
		stop
	Zoom:
		TNT1 A 0 A_JumpIfInventory("PowerIsZoom",1,"ReadyZoom")
		TNT1 A 0 A_JumpIfInventory("PowerZoomLevel2",1,"UnZoom")
		TNT1 A 0 A_JumpIfInventory("PowerZoomLevel1",1,"Zoom2")
		TNT1 A 0 A_ZoomFactor(2.0)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel2",1)
		TNT1 A 0 A_GiveInventory("PowerZoomLevel1",1)
		TNT1 A 0 A_GiveInventory("PowerIsZoom",1)
		Goto Ready
	Zoom2:
		TNT1 A 0 A_JumpIfInventory("PowerIsZoom",1,"ReadyZoom")
		TNT1 A 0 A_ZoomFactor(4.0)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel1",1)
		TNT1 A 0 A_GiveInventory("PowerZoomLevel2",1)
		TNT1 A 0 A_GiveInventory("PowerIsZoom",1)
		Goto Ready
	UnZoom:
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_GiveInventory("PowerIsZoom",1)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel1",1)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel2",1)
		Goto Ready
	}
}

Actor EtherealCrossbowPuff : BulletPuff
{
	Damagetype "PoisonPlayer"
	//+ALLOWTHRUFLAGS
	+MTHRUSPECIES /*+NODAMAGETHRUST*/ +DONTBLAST
	+THRUSPECIES
}

ACTOR EtherealCrossbowPuff2
{
	+NOBLOCKMAP
	+NOGRAVITY
	+PUFFONACTORS
	+PUFFGETSOWNER
	+HITTRACER
	RenderStyle Add
	Mass 5
	States
	{
	Spawn:
		FX03 H 0 Bright
		FX03 H 0 Bright ACS_NamedExecuteWithResult("WOC DAMAGE OVER TIME", ACS_ExecuteWithResult(WOC_DECORATE,STATS,WOCTID,WOCTRACER), ACS_NamedExecuteWithResult("WOC Player Scale", 20, AGILITY, ABIL_RANGEDMASTERY, WOCTARGET), 5, POISONDOT)
		FX03 HIJ 6 BRIGHT
		Stop
	}
}

ACTOR ECrossbowFX1
{
	Radius 11
	Height 8
	Speed 40
	Damage (ACS_NamedExecuteWithResult("WOC Player Scale", FRandom(35,55), AGILITY, ABIL_RANGEDMASTERY, WOCTARGET))
	Projectile
	+MTHRUSPECIES
	+DONTBLAST
	+HITTRACER
	RenderStyle Add
	SeeSound ""
	DeathSound "HunterEtherealCrossBowHit1"
	Damagetype "Poison"
	States
	{
	Spawn:
		FX03 B 1 BRIGHT A_SpawnItemEx("ECrossbowFX4", random2[BoltSpark]()*0.015625, random2[BoltSpark]()*0.015625,
                                  0, 0, 0, 0, 0, SXF_ABSOLUTEPOSITION, 50)
		Loop
	Death:
		FX03 H 0 Bright ACS_NamedExecuteWithResult("WOC DAMAGE OVER TIME", ACS_ExecuteWithResult(WOC_DECORATE,STATS,WOCTID,WOCTRACER), ACS_NamedExecuteWithResult("WOC Player Scale", 12, AGILITY, ABIL_RANGEDMASTERY, WOCTARGET), 5, POISONDOT)
		FX03 HIJ 6 BRIGHT
		Stop
	}
}

Actor ECrossbowFX2
{
	Height 2
	Radius 6
	Damage 0
	RenderStyle Add
	Alpha 1
	PROJECTILE
	+ForceXYBillBoard
	+NoGravity
	+ClientsideOnly
	+DropOff
	States
	{
	Spawn:
		FX03 BBBBBBBBBBBBBBBBBBBBBBBB 1 Bright A_FadeOut
		Stop
	}
}

Actor EtherealRail
{
	Height 2
	Radius 6
	Damage 0
	RenderStyle Add
	Alpha 1
	Scale 0.3
	PROJECTILE
	+ForceXYBillBoard
	+NoGravity
	+ClientsideOnly
	+DropOff
	States
	{
	Spawn:
		JWPR DDDDDDDDDD 1 Bright A_FadeOut(0.05)
		JWPR DDDDDDDDDD 1 Bright A_FadeOut(0.05)
		JWPR DDDDDDDDDD 1 Bright A_FadeOut(0.05)
		Stop
	}
}

Actor ECrossbowFX4 : CrossBowFX4
{
	+CLIENTSIDEONLY
	-NOGRAVITY
	States
	{
	Spawn:
		FX03 FFFFFGGGGG 1 Bright A_FadeOut
		Stop
	}
}

ACTOR ECrossbowFX3 : ECrossbowFX1
{
	Speed 30
	+THRUGHOST
	+WINDTHRUST
	Damage (ACS_NamedExecuteWithResult("WOC Player Scale", FRandom(15,30), AGILITY, ABIL_RANGEDMASTERY, WOCTARGET))
	SeeSound ""
	Damagetype "Physical"
	States
	{
	Spawn:
		FX03 A 1 BRIGHT A_SpawnItemEx("ECrossbowFX5",  -(MomX/1.2), -(MomY/1.2), (MomZ/1.2*-1), (MomX/1.2), (MomY/1.2), (MomZ/1.2), 0, 138)
		Loop
	Death:
		FX03 CDE 6 BRIGHT
		Stop
	}
}

Actor ECrossbowFX5
{
	Height 2
	Radius 6
	Damage 0
	RenderStyle Add
	Alpha 1
	PROJECTILE
	+ForceXYBillBoard
	+NoGravity
	+ClientsideOnly
	+DropOff
	States
	{
	Spawn:
		FX03 AAAAAAAAAAAAAAAAAAAAAAAA 1 Bright A_FadeOut
		Stop
	}
}