ACTOR GlacialCrossBow : Weapon
{
	Weapon.SelectionOrder 3
	Weapon.AmmoUse1 3
	Weapon.KickBack 100
	Weapon.AmmoGive1 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Mana1"
	Weapon.AmmoType2 "Mana1"
	Weapon.AmmoUse2 4
	+UNDROPPABLE
	Inventory.PickupMessage "Glacial Crossbow" // "ETHEREAL CROSSBOW"
	Obituary "%o should know that %k's is not a licensed acupuncturist"
	Tag "Glacial Crossbow"
	Weapon.BobStyle InverseSmooth
	Weapon.BobSpeed 2.1
	Weapon.BobRangeY 0.4
	Weapon.BobRangeX 0.5
	States
	{
	Spawn:
		XBOW Z -1
		Stop
	Ready:
		XBOW B 0 A_JumpIfInventory("IsMarksman",1,"ReadyZoom")
		XBOW BBCCDDEEFFEEDDCC 1 A_WeaponReady
		Loop
	ReadyZoom:
		XBOW BBCCDDEEFFEEDDCC 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")
		XBOW B 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")
		XBOW B 1 A_Raise
		TNT1 A 0 A_Raise
		Loop
	Fire:
		XBOW H 0 A_GiveInventory("MarksmanFocusCheck", 1)
		XBOW H 0 A_PlaySound("HunterCrossbowFire")
		XBOW H 1 Offset(0, 50) A_FireCustomMissile ("Glacialbolt")
		XBOW H 1 Offset(0, 49) A_SetPitch(Pitch-.5)
		XBOW H 1 Offset(0, 47) A_SetPitch(Pitch+.125)
		XBOW H 1 Offset(0, 46) A_SetPitch(Pitch+.125)
		XBOW H 1 Offset(0, 45) A_SetPitch(Pitch+.125)
		XBOW H 1 Offset(0, 44) A_SetPitch(Pitch+.125)
		XBOW H 1 Offset(0, 43)
		XBOW H 1 Offset(0, 42)
		XBOW I 1 Offset(0, 41)
		XBOW I 1 Offset(0, 40)
		XBOW I 1 Offset(0, 39)
		XBOW I 1 Offset(0, 38)
		XBOW I 1 Offset(0, 37)
		XBOW I 1 Offset(0, 36)
		XBOW J 1 Offset(0, 35)
		XBOW J 2 Offset(0, 34)
		XBOW J 2 Offset(0, 33)
		XBOW J 1 A_ReFire
		goto Ready
	AltFire:
		XBOW H 0 A_GiveInventory("MarksmanFocusCheck", 1)
		XBOW G 0 A_PlaySound("HunterCrossbowFire")
		XBOW H 1 Offset(0, 50) A_FireCustomMissile ("Glacialbolt2")
		XBOW H 1 Offset(0, 49) A_SetPitch(Pitch-.5)
		XBOW H 1 Offset(0, 48) A_SetPitch(Pitch+.125)
		XBOW H 1 Offset(0, 47) A_SetPitch(Pitch+.125)
		XBOW H 1 Offset(0, 46) A_SetPitch(Pitch+.125)
		XBOW H 1 Offset(0, 45) A_SetPitch(Pitch+.125)
		XBOW H 1 Offset(0, 44)
		XBOW H 1 Offset(0, 43)
		XBOW H 1 Offset(0, 42)
		XBOW I 1 Offset(0, 41)
		XBOW I 1 Offset(0, 40)
		XBOW I 1 Offset(0, 39)
		XBOW I 1 Offset(0, 38)
		XBOW I 1 Offset(0, 37)
		XBOW I 1 Offset(0, 36)
		XBOW J 1 Offset(0, 35)
		XBOW J 2 Offset(0, 34)
		XBOW J 1 Offset(0, 33)
		XBOW J 2
		goto Ready
	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_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 Glacialbolt : FastProjectile
{
	radius 3
	height 3
	speed 70
	Projectile
	+FORCERADIUSDMG
	+DONTFALL
	+NODAMAGETHRUST +DONTBLAST
	+THRUGHOST
	+WINDTHRUST
	+MTHRUSPECIES
	+DONTSPLASH
	+HITTRACER
	+FORCERADIUSDMG
	Damagetype "ICE"
	Renderstyle Add
	DeathSound "HunterCrossbowHit"
	
	var int user_z;
	var int user_timer;
	states
	{
	Spawn:
		CBLT A 1 Bright A_SpawnItemEx("GlacialboltTrail",0,0,0,frandom(-100, 100)/100.0,frandom(-100, 100)/100.0,frandom(-100, 100)/100.0,0,8)
		Loop
	Death:
		CBLT A 0 Bright A_SpawnItemEx("FrostFangFog2", 0, 0, 0)
		CBLT A 0 Bright A_SetUserVar("user_z", Z-ACS_ExecuteWithResult(WOC_DECORATE,STATS,ZPOSITION,WOCTRACER))
	Stuck:
		CBLT A 0 Bright A_JumpIf(user_timer >= 26, "Death2")
		CBLT A 1 Bright A_Warp(AAPTR_TRACER, 4, 0, user_z, 0, WARPF_NOCHECKPOSITION|WARPF_COPYINTERPOLATION)
		CBLT A 0 Bright A_Explode(ACS_NamedExecuteWithResult("WOC Player Scale", 2, AGILITY, ABIL_RANGEDMASTERY, WOCTARGET),8,0,0,8)
		CBLT A 0 Bright A_SetUserVar("user_timer", user_timer+1)
		Loop
	Death2:
		CTFX B 0 A_PlaySound("HunterIceCrossbowBreak")
		CTFX B 0 A_Explode(ACS_NamedExecuteWithResult("WOC Player Scale", 70, AGILITY, ABIL_RANGEDMASTERY, WOCTARGET),50,0)
		TNT1 AAAAAA 0 A_SpawnItemEx("GlacialBoltLightSpawner")
		CTFX B 4 Bright
		CTFX C 3 Bright
		CTFX D 4 Bright
		CTFX E 3 Bright
		CTFX F 2 Bright
		stop
	}
}

actor Glacialbolt2
{
	height 3
	radius 3
	damage (ACS_NamedExecuteWithResult("WOC Player Scale", FRandom(26,46), AGILITY, ABIL_RANGEDMASTERY, WOCTARGET))
	speed 45
	PROJECTILE
	+SEEKERMISSILE
	+THRUGHOST
	+WINDTHRUST
	+MTHRUSPECIES +NODAMAGETHRUST +DONTBLAST
	Renderstyle Add
	Damagetype "Ice"
	DeathSound "HunterIceCrossBowImpact"
	states
	{
	Spawn:
		CBLT A 1 A_SpawnItemEx("GlacialboltTrail2",0,0,0,frandom(-100, 100)/100.0,frandom(-100, 100)/100.0,frandom(-100, 100)/100.0,0,8)
		Loop
	Death:
		TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("GlacialboltWind", frandom(-3,3), frandom(-3,3), 0, frandom(-6,6), frandom(-6,6), frandom(-3,3))
		TNT1 A 1
		Stop
	}
}

actor GlacialboltWind
{
	PROJECTILE
	+RIPPER
	+BLOODLESSIMPACT
	+DOOMBOUNCE
	+MTHRUSPECIES +NODAMAGETHRUST +DONTBLAST
	+CANNOTPUSH
	-ALLOWBOUNCEONACTORS
	-BOUNCEONACTORS
	Damagetype "Ice"
	Damage (ACS_NamedExecuteWithResult("WOC Player Scale", FRandom(1,3), AGILITY, ABIL_RANGEDMASTERY, WOCTARGET))
	Radius 5
	renderstyle add
	alpha 0.8
	scale 0.6
	Height 8
	States
	{
	Spawn:
		FRSS JKLMNOPQRSTUVWXYZ 2 A_FadeOut(0.05)
		FRST ABC 2 A_FadeOut(0.05)
		stop
	Death:
		TNT1 A 1
		stop
	}
}

actor GlacialboltTrail2
{
	PROJECTILE
	+NOCLIP
	+NOINTERACTION
	+CLIENTSIDEONLY
	Radius 2
	renderstyle add
	alpha 0.8
	scale 0.4
	Height 4
	States
	{
	Spawn:
		FRSS JKLMNOPQRSTUVWXYZ 1 A_FadeOut(0.05)
		FRST ABC 1 A_FadeOut(0.05)
		stop
	Death:
		TNT1 A 1
		stop
	}
}

actor GlacialboltTrail
{
	PROJECTILE
	+NOCLIP
	+NOINTERACTION
	+CLIENTSIDEONLY
	Radius 1
	renderstyle add
	alpha 0.8
	scale 0.2
	Height 2
	States
	{
	Spawn:
		FRSS JKLMNOPQRSTUVWXYZ 1 A_FadeOut(0.05)
		FRST ABC 1 A_FadeOut(0.05)
		stop
	Death:
		TNT1 A 1
		stop
	}
}

ACTOR GlacialboltDust
{
	Radius 1
	Height 1
	Damage 0
	Speed 0
	Scale 0.1
	PROJECTILE
	+CLIENTSIDEONLY
	+NOINTERACTION
	RenderStyle Add
	//Alpha 0.50
	States
	{
	Spawn:
		TNT1 A 0
		FFFG A 2 BRIGHT A_FadeOut(0.09)
		Loop
	}
}

ACTOR GlacialBoltLightSpawner
{
	+NOBLOCKMAP
	+NOGRAVITY
	+NOSECTOR
	+NOINTERACTION
	+NOCLIP
	-SOLID
	+CLIENTSIDEONLY
	States
	{
	Spawn:
	Active:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(Args[1], "Circle")
		TNT1 A 2
		TNT1 A 0 A_SpawnItemEx ("GlacialboltDust", 0, 0, 0, frandom(-100,100)/100.0, frandom(-100,100)/100.0, frandom(-100,100)/100.0, frandom(0,360), 129, Args[2])
		TNT1 A 0 A_SpawnItemEx ("GlacialboltDust", 0, 0, 0, frandom(-100,100)/100.0, frandom(-100,100)/100.0, frandom(-100,100)/100.0, frandom(0,360), 129, Args[2])
		Stop
	Circle:
		TNT1 A 0
		TNT1 A 2 A_SpawnItemEx ("GlacialboltDust", 0, 0, 0, frandom(-100,100)/100.0, frandom(-100,100)/100.0, frandom(-100,100)/100.0, frandom(0,360), 129, Args[2])
		Loop
	Inactive:
		TNT1 A 1
		Loop
	}
}