actor sawglove : weapon
{
	Weapon.SelectionOrder 900
	Inventory.RestrictedTo "DoomSlayer"
	Weapon.AmmoUse 0
	Tag "sunder"
	Inventory.PickupMessage "You've picked up Sunder again, butterfingers"
	states
	{
	spawn:
		GNPU A 1
		loop
	select:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("overheat",1,"draw")
		TNT1 A 0 a_giveinventory ("UsingSlayerFists",1)
		TNT1 A 0 a_playsound ("doomslayer/sawup")
	draw:
		SNDR A 1 a_raise
		TNT1 A 0 a_takeinventory ("berserkfists",99)
		SNDR AA 0 a_raise
		loop
	cooldown:
		SNDR S 1 a_weaponready (WRF_NOFIRE|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
		TNT1 A 0 a_jumpifinventory ("overheat",1,"cooldown")
		TNT1 A 0 a_playsound ("doomslayer/sawup")
		SNDR CBA 1
		goto ready
	ready:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("overheat",1,"cooldown")
		TNT1 A 0 a_playsound ("doomslayer/sawidle",CHAN_WEAPON,1,1)
	sawready:
		TNT1 A 0 a_jumpifinventory ("raging",1,"ragestart")
		SNDR AB 1 a_weaponready (WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
		TNT1 A 0 a_jumpifinventory ("raging",1,"ragestart")
		loop
	Ragestart:
		TNT1 A 0
		TNT1 A 5 a_takeinventory ("raging",99)
		TNT1 A 0 a_stopsound (CHAN_WEAPON)
		TNT1 A 0 A_giveinventory ("berserkfists",1)
		TNT1 A 0 A_Quake(2, 20, 0, 10,"silence")			
		TNT1 A 0 a_setinvulnerable
		RAGE ABCDDEE 2
		RAGE E 4
		TNT1 A 0 A_Quake(1, 18, 0, 10,"silence")			
		RAGE F 2
		TNT1 A 0 a_playsound ("doomslayer/channelsly",0,1,0,0.6)
		TNT1 A 0 A_SetBlend("99 15 15", 0.6, 60)
		TNT1 A 0 a_spawnitemex ("ragesplosion")
		TNT1 A 0 a_radiusthrust (12000,150,0,150)
		TNT1 A 0 a_giveinventory ("health",35)
		TNT1 A 0 a_alertmonsters
		TNT1 A 0 a_takeinventory ("zerkcharge",1)
		RAGE G 1 A_Quake(7, 55, 0, 10)	
		RAGE G 1 offset (3,37)
		RAGE G 1 offset (-2,30)
		RAGE G 1 offset (4,36)
		RAGE G 1 offset (-4,32)
		RAGE G 1 offset (3,35)
		RAGE G 1 offset (-5,28)
		RAGE G 1 offset (2,37)
		RAGE G 1 offset (-1,31)
		RAGE G 1 offset (2,35)
		RAGE G 1 offset (3,37)
		RAGE G 1 offset (-2,30)
		RAGE G 1 offset (4,36)
		RAGE G 1 offset (-4,32)
		RAGE G 1 offset (3,35)
		RAGE G 1 offset (-5,28)
		RAGE G 1 offset (2,37)
		RAGE G 1 offset (-1,31)
		RAGE G 1 offset (2,35)
		RAGE G 1 offset (3,37)
		RAGE G 1 offset (-2,30)
		RAGE G 1 offset (4,36)
		RAGE G 1 offset (-4,32)
		RAGE G 1 offset (3,35)
		RAGE G 1 offset (-5,28)
		RAGE G 1 offset (2,37)
		RAGE G 1 offset (-1,31)
		RAGE G 1 offset (2,35)
		RAGE G 1 offset (3,37)
		RAGE G 1 offset (-2,30)
		RAGE G 1 offset (4,36)
		RAGE G 1 offset (-4,32)
		RAGE G 1 offset (3,35)
		RAGE G 1 offset (-5,28)
		RAGE G 1 offset (2,37)
		RAGE G 1 offset (-1,31)
		RAGE G 1 offset (2,35)
		RAGE G 1 offset (0,32)
		RAGE G 2 
		RAGE HI 2
		TNT1 A 1 
		TNT1 A 0 a_unsetinvulnerable
		TNT1 A 0 A_giveinventory ("berserkfists",1)
		TNT1 A 1 a_selectweapon ("berserkfists")
		
		TNT1 A 0 
		TNT1 A 0 a_takeinventory ("sawglove",1)
		TNT1 A 0 a_takeinventory ("morningstar",1)
		TNT1 A 0 a_takeinventory ("Thunderbuss",1)
		TNT1 A 0 a_takeinventory ("Hydrarepeater",1)
		TNT1 A 0 a_takeinventory ("wrathcaster",1)
		TNT1 A 0 a_takeinventory ("infernorifle",1)
		TNT1 A 1 
		TNT1 A 0 a_takeinventory ("rend",1)
		TNT1 A 1
		goto deadlower
	deselect:
		TNT1 A 0
		TNT1 A 0 a_stopsound (CHAN_WEAPON)
		TNT1 A 0 a_jumpifhealthlower (1, "deadlower")
	holster:
		TNT1 A 0
		SNDR A 1 a_lower
		TNT1 A 0 a_takeinventory ("UsingSlayerFists",99)
		SNDR AA 0 a_lower
		loop
	deadlower:
		TNT1 A 0
		TNT1 A 0
        TNT1 A 0 A_ClearRefire
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		loop
	fire:
		TNT1 A 0
		TNT1 A 0 a_stopsound (CHAN_WEAPON)
		TNT1 A 0 a_playsound ("doomslayer/sawstart",0)
		SNDR ABCDEF 1 
		TNT1 A 0 A_playsound ("doomslayer/sawloop",CHAN_WEAPON,1,1)
	sawing:
		SNDR G 1 a_jumpifcloser (120,"sawpunch")
		TNT1 A 0 A_Quake(1, 4, 0, 10,"silence")
		SNDR H 1 a_jumpifcloser (120,"sawpunch")
		TNT1 A 0 a_refire ("sawing")
		goto sawstop
	sawstop:
		TNT1 A 0
		TNT1 A 0 a_stopsound (CHAN_WEAPON)
		TNT1 A 0 a_playsound ("doomslayer/sawstop",0)
		SNDR FEDCBA 1
		goto ready
	sawpunch:
		TNT1 A 0
		TNT1 A 0 a_stopsound (CHAN_WEAPON)
		SNDR I 1
		SNDR J 1 a_firecustommissile ("sunderpunch")
		TNT1 A 0 a_playsound ("doomslayer/sawhit",0)
		SNDR K 1 
		SNDR T 1
		SNDR K 1
		SNDR T 1
		SNDR K 1
		SNDR LMNOP 1
		TNT1 A 0 a_playsound ("doomslayer/sawstop",0)
		TNT1 A 8
		SNDR QRS 2
		TNT1 A 0 a_jumpifinventory ("overheat",1,"swordswitch")
		SNDR CBA 2
		goto ready
	SwordSwitch:
		TNT1 A 0
		SNDR A 1 a_lower
		TNT1 A 0 a_selectweapon ("rend")
		TNT1 A 0 a_takeinventory ("UsingSlayerFists",99)
		SNDR AA 0 a_lower
		TNT1 A 0 a_selectweapon ("rend")
		loop
	Reload:
		"####" "#" 1 a_jumpifinventory ("SlayerBombCooldown",1, "quickpunch")
		TNT1 A 0 a_playsound ("doomslayer/zerkswing",0)
		DSUB AB 2
		TNT1 A 0 a_jumpifinventory ("Thunderbombcheck",1,"Thunderbomb")
		TNT1 A 0 a_jumpifinventory ("Firebombcheck",1,"Firebomb")
		TNT1 A 0 a_jumpifinventory ("Beambombcheck",1,"beambomb")
		DSUB C 1 a_firecustommissile ("spikebomb")
		TNT1 A 0 a_giveinventory ("SlayerBombCooldown",200)
		DSUB DEF 1
		TNT1 A 5 a_weaponready (WRF_ALLOWZOOM)
		goto ready
	quickpunch:
		TNT1 A 0
		TNT1 A 0 a_playsound ("doomslayer/zerkswing",0)
		BERS JK 2
		TNT1 A 0 a_playsound ("Doomslayer/unf",0)
		BERS L 2 a_firecustommissile ("quickpunch")
		BERS NO 2
		TNT1 A 4
		goto ready
	BeamBomb:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("bombammo",1)
		DSUB C 1 a_firecustommissile ("beambomb")
		TNT1 A 0 a_giveinventory ("SlayerBombCooldown",200)
		DSUB DEF 1
		TNT1 A 5 a_weaponready (WRF_ALLOWZOOM)
		goto ready
	FireBomb:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("bombammo",1)
		DSUB C 1 a_firecustommissile ("slayerfirebomb")
		TNT1 A 0 a_giveinventory ("SlayerBombCooldown",200)
		DSUB DEF 1
		TNT1 A 5 a_weaponready (WRF_ALLOWZOOM)
		goto ready
	ThunderBomb:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("bombammo",1)
		DSUB C 1 a_firecustommissile ("slayerThunderbomb")
		TNT1 A 0 a_giveinventory ("SlayerBombCooldown",200)
		DSUB DEF 1
		TNT1 A 5 a_weaponready (WRF_ALLOWZOOM)
		goto ready
		
		

	Zoom:
		TNT1 A 0 
		"####" "#" 1 a_jumpifinventory ("SlayerDaggerCooldown",1, "quickpunch")
		TNT1 A 0 a_playsound ("doomslayer/zerkswing",0)
		DSUB AB 2
		TNT1 A 0 a_jumpifinventory ("FoodDaggercheck",1, "FoodDagger")
		TNT1 A 0 a_jumpifinventory ("AmmoDaggercheck",1, "AmmoDagger")
		TNT1 A 0 a_jumpifinventory ("SpreadDaggercheck",1, "SpreadDagger")
		TNT1 A 0 a_jumpifinventory ("GlassDaggercheck",1, "GlassDagger")
		DSUB C 1 a_firecustommissile ("draindagger")
		TNT1 A 0 a_giveinventory ("SlayerDaggerCooldown",200)
		DSUB DEF 1
		TNT1 A 5 a_weaponready (WRF_ALLOWRELOAD)
		goto ready
	GlassDagger:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("daggerammo",1)
		DSUB C 1 a_firecustommissile ("Glassdagger")
		TNT1 A 0 a_giveinventory ("SlayerDaggerCooldown",200)
		DSUB DEF 1
		TNT1 A 5 a_weaponready (WRF_ALLOWRELOAD)
		goto ready
	SpreadDagger:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("daggerammo",1)
		TNT1 A 0 a_firecustommissile ("SpreadDagger",-16)
		TNT1 A 0 a_firecustommissile ("SpreadDagger",-8)
		TNT1 A 0 a_firecustommissile ("SpreadDagger",-4)
		TNT1 A 0 a_firecustommissile ("SpreadDagger",4)
		TNT1 A 0 a_firecustommissile ("SpreadDagger",8)
		TNT1 A 0 a_firecustommissile ("SpreadDagger",16)
		DSUB C 1 a_firecustommissile ("Spreaddagger")
		TNT1 A 0 a_giveinventory ("SlayerDaggerCooldown",200)
		DSUB DEF 1
		TNT1 A 5 a_weaponready (WRF_ALLOWRELOAD)
		goto ready
	AmmoDagger:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("daggerammo",1)
		DSUB C 1 a_firecustommissile ("Ammodagger")
		TNT1 A 0 a_giveinventory ("SlayerDaggerCooldown",200)
		DSUB DEF 1
		TNT1 A 5 a_weaponready (WRF_ALLOWRELOAD)
		goto ready
	FoodDagger:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("daggerammo",1)
		DSUB C 1 a_firecustommissile ("Fooddagger")
		TNT1 A 0 a_giveinventory ("SlayerDaggerCooldown",200)
		DSUB DEF 1
		TNT1 A 5 a_weaponready (WRF_ALLOWRELOAD)
		goto ready

	}
}

actor sunderpunch : fastprojectile
{
	+dontblast
	+notimefreeze
	+BLOODSPLATTER
	+FORCEXYBILLBOARD		
	+thruspecies
	+EXTREMEDEATH
	+FORCEPAIN
	species "friendly"
	damagetype sunder
	projectilekickback 600
	projectile
	radius 16
	height 10
	speed 100
	damage (650)
	states
	{
	spawn:
		TNT1 AA 1
		TNT1 A 1 a_fadeout (1)
		stop
	death:
        TNT1 A 0
        TNT1 A 1
		TNT1 A 0 Radius_Quake (1,5,0,10,0)
		SWMS ABC 3 bright
		stop
	crash:
        TNT1 A 0
        TNT1 A 1
		TNT1 A 0 Radius_Quake (1,5,0,10,0)
		SWMS ABC 3 bright
		stop
	xdeath:
        TNT1 A 0
        TNT1 A 1 a_jumpifintargetinventory ("unleasher",1,"givecharge")
		TNT1 A 0 Radius_Quake (4,9,0,10,0)
		TNT1 A 0 a_spawnitemex ("sunderlootorb", 0, 0, 0, random (-7, 10), random (-4, 10), random (5, 7))
		TNT1 A 0 a_spawnitemex ("sunderlootorb", 0, 0, 0, random (-4, 7), random (-6, 3), random (3, 6))
		TNT1 A 0 a_spawnitemex ("sunderlootorb", 0, 0, 0, random (-4, 7), random (-6, 3), random (3, 6))
		TNT1 A 0 a_spawnitemex ("sunderlootorb", 0, 0, 0, random (-3, 6), random (-8, 8), random (3,5))
		TNT1 A 0 a_spawnitemex ("sunderlootorb", 0, 0, 0, random (-8, 5), random (-3, 5), random (2, 6))
		TNT1 A 0 A_giveinventory ("overheat", 600, AAPTR_TARGET)   
		SWHT ABC 3 bright
		stop
	givecharge:
		TNT1 A 0 Radius_Quake (4,9,0,10,0)
		TNT1 A 0 a_spawnitemex ("sunderlootorb", 0, 0, 0, random (-7, 10), random (-4, 10), random (5, 7))
		TNT1 A 0 a_spawnitemex ("sunderlootorb", 0, 0, 0, random (-4, 7), random (-6, 3), random (3, 6))
		TNT1 A 0 a_spawnitemex ("sunderlootorb", 0, 0, 0, random (-3, 6), random (-8, 8), random (3,5))
		TNT1 A 0 a_spawnitemex ("sunderlootorb", 0, 0, 0, random (-3, 6), random (-8, 8), random (3,5))
		TNT1 A 0 a_spawnitemex ("sunderlootorb", 0, 0, 0, random (-8, 5), random (-3, 5), random (2, 6))
		TNT1 A 0 A_giveinventory ("overheat", 600, AAPTR_TARGET)
		TNT1 A 0 A_GiveInventory("zerkcharge",15, AAPTR_TARGET)
		SWHT ABC 3 bright
		stop
		
	}
}

actor sunderlootorb 
{
	projectile
	+notimefreeze
    +FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+thruactors
	+bounceonwalls
	+bright
	species "friendly"
	-nogravity
	radius 12
	speed 5
	damage (0)
	height 20
    gravity 0.8
	states
	{
	spawn:
		MGCS B 1
		MGCS D 1
		loop
	death:
		TNT1 A 0
		TNT1 A 1 a_dropitem ("sunderloot",1,256)
		AMDP ABCDE 2
		stop
	}
}

actor sunderloot : randomspawner
{
	dropitem "smallbulletgemdrop", 256, 2
	dropitem "minorarcanecrystaldrop", 256, 2
}


actor strongsunderlootorb : sunderlootorb 
{
	scale 1.5
	states
	{
	death:
		TNT1 A 0
		TNT1 A 1 a_dropitem ("strongsunderloot",1,256)
		AMDP ABCDE 2
		stop
	}
}

actor strongsunderloot : randomspawner
{
	dropitem "smalldarkgemdrop", 256, 2
	dropitem "smallspiritgemdrop", 256, 2
}
