actor havocrebounder : weapon
{
	+AMMO_OPTIONAL
	+cheatnotweapon
	Weapon.SelectionOrder 20
	Inventory.PickupSound "ZTweapons/flareclose"
	Inventory.PickupMessage "You got the Havoc rebounder!"
	states
	{
	spawn:
		BAL1 A 15
		BAL1 A 4 bright
		loop
	select:
		TNT1 A 0
		TNT1 A 0 a_playsound ("rebounder/draw",0)
	draw:	
		TNT1 A 0
		HVRB AAAA 0 A_Raise
		HVRB A 1 A_Raise
		loop
	deselect:
		TNT1 A 0
		TNT1 A 0 a_jumpifhealthlower (1, "deadlower")
		TNT1 A 0 a_playsound ("rebounder/holster",0)
	holster:
		TNT1 A 0
		HVRB A 1 a_lower
		TNT1 A 0 a_takeinventory ("secretaction", 99)
		TNT1 AA 0 a_lower
		loop
	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		wait		
	ready:
		HVRB A 1 a_weaponready 
		loop
	fire:
		HVRB A 4
		TNT1 A 0 a_playsound ("rebounder/beam", 0)
		TNT1 A 0 A_Quake(1, 7, 0, 32)
		HVRB B 3 bright a_firecustommissile ("reboundbeam")
		HVRB C 3
		HVRB D 3
		TNT1 A 0 a_playsound ("rebounder/chargeup", 4)
		HVRB DEFG 4
		HVRB A 1 bright
		TNT1 A 0 a_playsound ("rebounder/armed", 4)
		HVRB A 4
		goto Ready
	altfire:
		HVRB A 4
		TNT1 A 0 a_playsound ("rebounder/pulse", 0)
		TNT1 A 0 A_Quake(1, 7, 0, 32)
		HVRB H 4 bright a_firecustommissile ("bouncepulse")
		HVRB C 5
		HVRB D 7
		TNT1 A 0 a_playsound ("rebounder/chargeup", 4)
		HVRB DEFG 5
		HVRB A 1 bright
		TNT1 A 0 a_playsound ("rebounder/armed", 4)
		HVRB A 5
		goto Ready
		
	}
}

actor reboundbeam
{
	+notimefreeze
	projectile
    +FORCEXYBILLBOARD	
	RenderStyle Add
	species "player"
	Decal DoomImpScorch
	+thruspecies
	+RANDOMIZE
	+hexenbounce
	+bounceonactors
	+USEBOUNCESTATE
	wallbouncefactor 1.1
	bouncecount 12
	height 4
	radius 12
	speed 40
	damage (25)
    Scale 1
	alpha 0.95
	
	var int user_reboundcount;
	states
	{
	spawn:
		HRB1 A 0
		TNT1 A 0 a_jumpif (user_reboundcount >=4, "crit")
		TNT1 A 0 a_jumpif (user_reboundcount >=2, "beamlvl3")		
		TNT1 A 0 a_jumpif (user_reboundcount >=1, "beamlvl2")
		HRB1 A 0 A_SpawnItemEx("reboundbeamtrail")
		HRB1 A 1 bright  A_SpawnItemEx("reboundbeamtrail")
		HRB1 A 0 A_SpawnItemEx("reboundbeamtrail")
		HRB1 A 0 A_SpawnItemEx("reboundbeamtrail")
		HRB1 A 1 bright  A_SpawnItemEx("reboundbeamtrail")
		HRB1 A 0 A_SpawnItemEx("reboundbeamtrail")
		HRB1 A 0 A_SpawnItemEx("reboundbeamtrail")
		HRB1 B 1 bright  A_SpawnItemEx("reboundbeamtrail")
		HRB1 A 0 A_SpawnItemEx("reboundbeamtrail")
		HRB1 A 0 A_SpawnItemEx("reboundbeamtrail")
		HRB1 B 1 bright  A_SpawnItemEx("reboundbeamtrail")
		HRB1 A 0 A_SpawnItemEx("reboundbeamtrail")
		loop
	beamlvl2:
		HRB2 A 0
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail2")
		HRB2 A 1 bright A_SpawnItemEx("reboundbeamtrail2")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail2")
		HRB2 A 1 bright A_SpawnItemEx("reboundbeamtrail2")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail2")
		HRB2 A 1 bright A_SpawnItemEx("reboundbeamtrail2")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail2")
		HRB2 B 1 bright A_SpawnItemEx("reboundbeamtrail2")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail2")
		HRB2 B 1 bright A_SpawnItemEx("reboundbeamtrail2")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail2")
		HRB2 B 1 bright A_SpawnItemEx("reboundbeamtrail2")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail2")
		loop
	beamlvl3:
		HRB3 A 0
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail3")
		HRB3 A 1 bright A_SpawnItemEx("reboundbeamtrail3")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail3")
		HRB3 A 1 bright A_SpawnItemEx("reboundbeamtrail3")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail3")
		HRB3 A 1 bright A_SpawnItemEx("reboundbeamtrail3")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail3")
		HRB3 A 1 bright A_SpawnItemEx("reboundbeamtrail3")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail3")
		HRB3 B 1 bright A_SpawnItemEx("reboundbeamtrail3")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail3")
		HRB3 B 1 bright A_SpawnItemEx("reboundbeamtrail3")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail3")
		HRB3 B 1 bright A_SpawnItemEx("reboundbeamtrail3")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail3")
		HRB3 B 1 bright A_SpawnItemEx("reboundbeamtrail3")
		TNT1 A 0 A_SpawnItemEx("reboundbeamtrail3")
		loop
	bounce.floor:
	bounce.wall:
		TNT1 A 0
		TNT1 AAAAAAAA 0 a_spawnitemex ("POWbreakage",Frandom(-16,16),Frandom(-16,16),Frandom(-10,10),Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,0,160)
		TNT1 A 0 a_playsound ("rebounder/ricochet",0)
		goto spawn
	bounce.actor.creature:	
	bounce.actor:
		TNT1 A 0
		TNT1 A 0 a_jumpif (user_reboundcount >=4, "crit")
		TNT1 A 0 a_jumpif (user_reboundcount >=2, "bouncelvl3")
		TNT1 A 0 a_jumpif (user_reboundcount >=1, "bouncelvl2")
		TNT1 A 0 a_setuservar ("user_reboundcount", user_reboundcount +1)
		TNT1 A 0 a_playsound ("rebounder/beamhit1",0,1,0,0.75)
		TNT1 A 0 A_explode (35,60,0)
		TNT1 A 0 a_spawnitemex ("reboundhitspark1")
		goto spawn
	bouncelvl2:
		TNT1 A 0
		TNT1 A 0 a_setuservar ("user_reboundcount", user_reboundcount +1)
		TNT1 A 0 a_playsound ("rebounder/beamhit2",0,1,0,0.75)
		TNT1 A 0 A_explode (90,85,0)
		TNT1 A 0 a_spawnitemex ("reboundhitspark2")
		goto spawn
	bouncelvl3:
		TNT1 A 0
		TNT1 A 0 a_setuservar ("user_reboundcount", user_reboundcount +1)
		TNT1 A 0 a_playsound ("rebounder/beamhit3",0,1,0,0.75)
		TNT1 A 0 A_explode (150,100,0)
		TNT1 A 0 a_spawnitemex ("reboundhitspark3")
		goto spawn
	Death:
		TNT1 A 0
		TNT1 A 0 a_stop
		TNT1 A 0 a_fall
		HRB2 CDE 2 bright
		stop
	crit:
		PLZM H 0
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 a_spawnitemex ("POWbreakage",Frandom(-16,16),Frandom(-16,16),Frandom(-10,10),Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,0,160)
		TNT1 A 0 a_playsound ("rebounder/beamcrit",0)
		TNT1 A 0 A_explode (250,100,0)
		PSMH DEFGH 2 bright
		stop
	}
}

actor reboundbeamtrail
{
	RenderStyle add
	Alpha 0.95
	Scale 0.7
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	Spawn:
		HRB1 A 0
		HRB1 A 2 A_SetTranslucent(0.70, 1)
		HRB1 B 2 A_SetTranslucent(0.65, 1)
		HRB1 A 2 A_SetTranslucent(0.55, 1)
		HRB1 B 2 A_SetTranslucent(0.50, 1)
		HRB1 A 2 A_SetTranslucent(0.40, 1)
		HRB1 B 2 A_SetTranslucent(0.35, 1)
		HRB1 A 2 A_SetTranslucent(0.15, 1)
		HRB1 B 2 A_SetTranslucent(0.10, 1)
		Stop
	}
}	

actor reboundbeamtrail2 : reboundbeamtrail
{
	RenderStyle add
	Alpha 0.95
	Scale 0.7
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	Spawn:
		HRB2 A 0
		HRB2 A 2 A_SetTranslucent(0.70, 1)
		HRB2 B 2 A_SetTranslucent(0.65, 1)
		HRB2 A 2 A_SetTranslucent(0.55, 1)
		HRB2 B 2 A_SetTranslucent(0.50, 1)
		HRB2 A 2 A_SetTranslucent(0.40, 1)
		HRB2 B 2 A_SetTranslucent(0.35, 1)
		HRB2 A 2 A_SetTranslucent(0.15, 1)
		HRB2 B 2 A_SetTranslucent(0.10, 1)
		Stop
	}
}	

actor reboundbeamtrail3 : reboundbeamtrail
{
	RenderStyle add
	Alpha 0.95
	Scale 0.7
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	Spawn:
		HRB3 A 0
		HRB3 A 3 A_SetTranslucent(0.70, 1)
		HRB3 B 3 A_SetTranslucent(0.65, 1)
		HRB3 A 3 A_SetTranslucent(0.55, 1)
		HRB3 B 3 A_SetTranslucent(0.50, 1)
		HRB3 A 3 A_SetTranslucent(0.40, 1)
		HRB3 B 3 A_SetTranslucent(0.35, 1)
		HRB3 A 3 A_SetTranslucent(0.15, 1)
		HRB3 B 3 A_SetTranslucent(0.10, 1)
		Stop
	}
}	


actor reboundhitspark1
{
	RenderStyle add
	Alpha 0.95
	Scale 0.60
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	spawn:
		TNT1 A 0
		HRB2 CDE 2 bright
		stop
	}
}

actor reboundhitspark2 : reboundhitspark1
{
	states
	{
	spawn:
		TNT1 A 0
		HRB1 CDE 4 bright
		stop
	}
}

actor reboundhitspark3 : reboundhitspark1
{
	states
	{
	spawn:
		TNT1 A 0
		HRB3 CDE 5 bright
		stop
	}
}

actor bouncepulse
{
	Radius 7
	Height 9
	scale 1
	Speed 30
	+bright
	+thruspecies
	+BOUNCEONACTORS
	+usebouncestate
	+DONTBLAST
	species "player"
	renderstyle add
	alpha 0.80
	Damage (30)
	Projectile
	gravity 0.70
	-NOGRAVITY
	+hexenbounce
	wallbouncefactor 1.1
	BounceCount 40
	projectilekickback 1000
	seesound "rebounder/pulsebounce"
	
	var int user_bouncecount;
	states
	{
	spawn:
		TNT1 A 0
		TNT1 A 0 a_jumpif (user_bouncecount >=4, "death")
		TNT1 A 0 a_jumpif (user_bouncecount >=2, "pulselvl3")
		TNT1 A 0 a_jumpif (user_bouncecount >=1, "pulselvl2")
		RBN1 AB 3 bright
		loop
	pulselvl2:
		TNT1 A 0
		TNT1 A 0 a_jumpif (user_bouncecount >=4, "death")
		TNT1 A 0 a_jumpif (user_bouncecount >=2, "pulselvl3")
		RBN2 AB 4 bright
		loop
	pulselvl3:
		TNT1 A 0
		TNT1 A 0 a_jumpif (user_bouncecount >=4, "death")
		RBN3 ABC 2 bright
		loop
	bounce.actor.creature:
	bounce.actor:
		TNT1 A 0
		TNT1 A 0 a_jumpif (user_bouncecount >=2, "hitlvl3")
		TNT1 A 0 a_jumpif (user_bouncecount >=1, "hitlvl2")
		TNT1 A 0 a_setuservar ("user_bouncecount", user_bouncecount -1)
		TNT1 A 0 a_playsound ("rebounder/pulsehit1",0)
		TNT1 A 0 a_spawnitemex ("bouncespark1")
		TNT1 A 0 a_explode (20,40,0)
		goto spawn
	hitlvl2:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("bouncespark2")
		TNT1 A 0 a_playsound ("rebounder/pulsehit2",0)
		TNT1 A 0 a_explode (50,80,0)
		TNT1 A 0 a_setuservar ("user_bouncecount", user_bouncecount -1)
		goto spawn
	hitlvl3:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("bouncespark3")
		TNT1 A 0 a_playsound ("rebounder/pulsehit3",0)
		TNT1 A 0 a_explode (100,120,0)
		TNT1 A 0 a_setuservar ("user_bouncecount", user_bouncecount -1)
		goto spawn
	bounce.floor:	
		TNT1 A 0
		TNT1 A 0 a_jumpif (user_bouncecount >=4, "death")
		TNT1 A 0 a_jumpif (user_bouncecount >=2, "bouncelvl3")
		TNT1 A 0 a_jumpif (user_bouncecount >=1, "bouncelvl2")
		TNT1 A 0 a_setuservar ("user_bouncecount", user_bouncecount +1)
		TNT1 A 0 a_playsound ("rebounder/pulsefloor1",0)
		TNT1 A 0 A_SpawnDebris("bounceparticle")
		TNT1 A 0 ThrustThing(angle*256/360, 5, 0, 0)
		TNT1 A 0 thrustthingz (0,25,0,0)
		goto spawn
	bouncelvl2:
		TNT1 A 0
		TNT1 A 0 a_setuservar ("user_bouncecount", user_bouncecount +1)
		TNT1 A 0 ThrustThing(angle*256/360, 5, 0, 0)
		TNT1 A 0 a_playsound ("rebounder/pulsefloor2",0)
		TNT1 A 0 A_SpawnDebris("bounceparticle")
		TNT1 A 0 thrustthingz (0,30,0,0)
		goto spawn
	bouncelvl3:
		TNT1 A 0
		TNT1 A 0 a_setuservar ("user_bouncecount", user_bouncecount +1)
		TNT1 A 0 a_playsound ("rebounder/pulsefloor3",0)
		TNT1 A 0 A_SpawnDebris("bounceparticle")
		TNT1 A 0 ThrustThing(angle*256/360, 5, 0, 0)
		TNT1 A 0 thrustthingz (0,35,0,0)
		goto spawn
	Death:
		PLZM H 0
		TNT1 A 0 a_changeflag ("nogravity",1)
		TNT1 A 0 radius_quake (3,8,0,20,0)
		TNT1 A 0 a_playsound ("rebounder/pulseburst",0)
		TNT1 A 0 A_explode (350,300,0)
		TNT1 A 0 a_spawnitemex ("bouncespark3")
		TNT1 A 0 A_SpawnDebris("bounceparticle")
		TNT1 A 0 A_SpawnDebris("bounceparticle")
		TNT1 A 0 A_SpawnDebris("bounceparticle")
		TNT1 A 8
		stop
	}
}

actor bouncespark1
{
	RenderStyle add
	Alpha 0.95
	Scale 0.60
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTBLAST
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	spawn:
		TNT1 A 0
		RBN1 CDEFG 2 bright
		stop
	}
}

actor bouncespark2 : bouncespark1
{
	states
	{
	spawn:
		TNT1 A 0
		RBN2 CDEFGH 2 bright
		stop
	}
}

actor bouncespark3 : bouncespark1
{
	scale 0.50
	states
	{
	spawn:
		TNT1 A 0
		RBN3 DEFGH 4 bright
		stop
	}
}

ACTOR bounceparticle
{
	Health 4
	radius 3
	height 6
	speed .1
	RenderStyle ADD
	Alpha		1
	Scale 0.5
	Mass		0
	+missile
	+doombounce
	+FLOORCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
		RBN1 A 1
		RBN1 AAAA 1  Bright 
		RBN1 AAAAAA 1  Bright A_SetTranslucent(.4,1)
		RBN1 AAAAAAAA 1 Bright A_SetTranslucent(.2,1)
		Stop
	}
}

actor reboundertoken : custominventory
{
	+notimefreeze
	Inventory.PickupSound "rebounder/get"
	Inventory.PickupMessage "You got the Havoc rebounder!"
	states
	{
	spawn:
		RBPU A 8 bright
		RBPU A 5
		loop
	pickup:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("flaregun", 1, "dropflare")
		TNT1 A 0 a_jumpifinventory ("tsbrick", 1, "dropbrick")
		TNT1 A 0 a_giveinventory ("havocrebounder", 1)
		stop
	dropflare:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("droppedflare", 1)
		TNT1 A 0 a_takeinventory ("flaregun", 1)
		TNT1 A 0 a_giveinventory ("havocrebounder", 1)
		stop
	dropbrick:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("droppedbrick", 1)
		TNT1 A 0 a_takeinventory ("TSbrick", 1)
		TNT1 A 0 a_giveinventory ("havocrebounder", 1)
		stop
	}
}

actor droppedrebounder
{
	+notimefreeze
	renderstyle ADD
	alpha 0.50
	states
	{
	spawn:
		RBPU A 60
		goto death
	death:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("reboundertoken")
		stop
	}
}
