//   HYDRA HM9 AUTOMATIC SHOTGUN
////////////////////

actor hydrashotgun : Shotgun replaces Shotgun {
	Tag "Hydra Shotgun"

	weapon.selectionorder 200
	inventory.pickupsound "weapons/hs_bolt"
	inventory.pickupmessage "Hydra HM9 Automatic Shotgun"

	weapon.ammotype "hydraclip"
	weapon.ammotype2 "autoshot_ammo"
	weapon.ammouse 0//1
	weapon.ammogive2 8
	weapon.ammogive1 0
	weapon.kickback 100
	Weapon.preferredSkin "AutoShotSkin"
	//weapon.bobstyle inverse
	//weapon.bobrangeX 0.4
	//weapon.bobrangeY 0.75
	//weapon.bobspeed 2.5
	AttackSound ""
	+AMMO_OPTIONAL
	+NOALERT
	+WEAPON.NOAUTOAIM
	scale 0.32

	states{	
		spawn:
			HASW A -1
    		stop
		ready:
			HASI A 1 A_WeaponReady
			NULL A 0 A_JumpIfInventory("TossGrenade", 1, "Grenade")
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer",1,"Sprint")
			NULL A 0 A_JumpIfInventory("ReloadingWeapon",1,"Reload")
			loop
		
		/////
		Sprint:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SprStart")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto ready
		SprStart:
			TNT1 A 0 A_PlaySound("sfx/sprintstart",CHAN_AUTO)
			TNT1 A 0 ACS_ExecuteAlways(Player_ChangeSpeed,0,200,0,0)
			TNT1 A 0 A_SetBlend("49 99 0",0.4,15)
			TNT1 A 0 A_Recoil(-15)
			HASS ABCDE 1 //Offset(-25,33)
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "SprLoop1")
			goto SprEnd
	    SprLoop1:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SL1")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto SprEnd
		SL1:
			HASS E 1 Offset(-14,33)
			//HASS E 1 Offset(-27,36)
			HASS E 1 Offset(-34,39)
			HASS E 1 Offset(-40,44)
			HASS E 1 Offset(-43,47)
			HASS E 1 Offset(-44,50)
		
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "SprLoop2")
			goto SprEnd
		SprLoop2:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SL2")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto SprEnd
		SL2:
			HASS E 1 Offset(-44,50)
			//HASS E 1 Offset(-43,47)
			HASS E 1 Offset(-40,44)
			HASS E 1 Offset(-34,39)
			HASS E 1 Offset(-27,36)
			HASS E 1 Offset(-14,33)
			TNT1 A 0 A_TakeInventory("PlayerStamina", 4)
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "SprLoop3")
			goto SprEnd
		SprLoop3:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SL3")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto SprEnd
		SL3:
			HASS E 1 Offset(14,33)
			//HASS E 1 Offset(27,36)
			HASS E 1 Offset(34,39)
			HASS E 1 Offset(40,44)
			HASS E 1 Offset(43,47)
			HASS E 1 Offset(44,50)
	
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "SprLoop4")
			goto SprEnd
		SprLoop4:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SL4")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto SprEnd
		SL4:
			HASS E 1 Offset(44,50)
			//HASS E 1 Offset(43,47)
			HASS E 1 Offset(40,44)
			HASS E 1 Offset(34,39)
			HASS E 1 Offset(27,36)
			HASS E 1 Offset(14,33)
			TNT1 A 0 A_TakeInventory("PlayerStamina", 4)
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "SprLoop1")
		SprEnd:
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
			TNT1 A 0 ACS_ExecuteAlways(Player_ChangeSpeed,0,100,0,0)
			TNT1 A 0 A_PlaySound("sfx/sprintend",CHAN_AUTO)
			HASS EDCBA 1 //Offset(-25,33)
			goto ready		
			
		
		Select:
			//TNT1 A 0 A_SetCrosshair(10)
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory",12,"GrenadeEnd")
			NULL A 8
			HASU F 1  A_PlaySound("weapons/hs_select", CHAN_WEAPON)
			HASU EDCBA 1
			NULL A 0 A_GiveInventory("xhair_switch",1)
		SelectLoop:
      		HASI A 1 A_Raise
      		Goto SelectLoop
		
		deselect:
			NULL A 0 A_TakeInventory("xhair_switch",1)
			HASU A 1 A_PlaySound("weapons/hs_deselect", CHAN_WEAPON)
			HASU BCDEF 1
			NULL A 2 
		deselectLoop:
			NULL A 1 A_Lower
			Goto deselectLoop
			
 		Fire:
			TNT1 A 0 A_JumpIfInventory("hydraclip", 1, 3)
			HASI A 1 A_PlaySound("weapons/noammo", CHAN_WEAPON)
			HASI A 6
			goto ready
			
			TNT1 A 0 A_TakeInventory("HydraClip", 1)
			
			TNT1 A 0 A_PlayWeaponSound("weapons/hs_fire")
			TNT1 A 0 A_AlertMonsters
			TNT1 A 0 A_GunFlash
			
			TNT1 A 1 A_FireBullets (4,3,9, 12 * 2,"buckshot_impact", FBF_NORANDOM | FBF_USEAMMO)
						
			//TNT1 A 0 ACS_ExecuteAlways(Weapon_Recoil,0,35,random(-25,25),0)
			TNT1 A 0 A_Light0
			TNT1 A 0 A_FireCustomMissile("regshell_spawner",0,0,0,3,0)
			HASI D 2
			HASI CB 1 
			HASI A 3
			goto ready
		Flash:
			TNT1 A 0 A_Jump(220, "firef1", "firef2")
		firef1:
			HASF A 1 bright A_Light2
			TNT1 A 1 A_Light1
			TNT1 A 1 A_Light0
			stop
		firef2:
			HASF B 1 bright A_Light2
			TNT1 A 1 A_Light1
			TNT1 A 1 A_Light0
			stop
			
		Reload:
			NULL A 0 A_JumpIfInventory("hydraclip", 16, 2)
			NULL A 0 A_JumpIfInventory("autoshot_ammo", 1, 2)
			NULL A 0
			goto ready			
				
			HARS ABCDEFG 1
			HARS H 4 A_PlaySound("weapons/hs_clipout", CHAN_WEAPON)
			HARS IJJ 1
			HARS K 8
			HARS LMNOP 1
			HARS Q 15
			HARS RST 1
			HARS U 1 A_PlaySound("weapons/hs_clipin", CHAN_WEAPON)
			HARS V 1 
			HARS W 8
			TNT1 A 0 A_JumpIfInventory("hydraclip", 1, "Reload_FillClipB")
			
		Reload_FillClipA:	
			NULL A 0 A_TakeInventory("autoshot_ammo",1)
			NULL A 0 A_GiveInventory("hydraclip",1)
			NULL A 0 A_JumpIfInventory("hydraclip",16,"ReloadFinish_Long")
			NULL A 0 A_JumpIfInventory("autoshot_ammo",1,"Reload_FillClipA")
		ReloadFinish_Long:	
			HARL ABCDD 1
			HARL E 3 A_PlaySound("weapons/hs_bolt", CHAN_WEAPON)
			HARL FGHH 1
			HARL I 8
			HARL KMNOP 1		
			goto ready
		
		Reload_FillClipB:	
			NULL A 0 A_TakeInventory("autoshot_ammo",1)
			NULL A 0 A_GiveInventory("hydraclip",1)
			NULL A 0 A_JumpIfInventory("hydraclip",16,"ReloadFinish_Quick")
			NULL A 0 A_JumpIfInventory("autoshot_ammo",1,"Reload_FillClipB")	
		ReloadFinish_Quick:
			HARQ ABCDEFG 1
			goto ready	
					
		Grenade:
			TNT1 A 0 A_JumpIfInventory("grenades", 1, 2)
			TNT1 A 0
			goto ready
			HASG ABCDEFG 1
			TNT1 A 0 A_GiveInventory("gtoss_weaponmemory", 12)
			TNT1 A 0 A_SelectWeapon("grenade_toss")
			goto deselectLoop
		GrenadeEnd:
			TNT1 A 0 A_TakeInventory("gtoss_weaponmemory",99)
			HASG GFEDCBA 1
			goto selectLoop
		AltFire:
			HASM C 1 A_Recoil(-6)
			NULL A 0 A_PlayWeaponSound("sfx/meleeswing")
			HASM EHJ 1
			HASM L 9 A_CustomPunch ((164+random(1,32)), 1 , 0 , "meleepuff",88)
			HASM KJIHGFEDCBA 1
			goto ready
	}
}

actor hydraclip : ammo{
	Inventory.MaxAmount 16
	Inventory.Icon "NULLA0"
	+INVENTORY.IGNORESKILL
}


actor buckshot_impact{		
	Radius 1
	Height 1
	Alpha 1
	DamageType buckshot_damage
	RenderStyle ADD
	Scale 0.16
	+NOGRAVITY
	+NOBLOCKMAP
	+FLOORCLIP
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+NOEXTREMEDEATH
	+NOINTERACTION
	+PUFFONACTORS
	+CLIENTSIDEONLY
	States{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_PlaySound("sfx/bulletric")
			TNT1 A 0 A_SpawnItemEx ("buckshot_flare", 0, 0, 0,  0,0,0, 0)
			TNT1 AAAA 0 A_SpawnItemEx ("buckshot_spark", 0, 0, 0, /*f*/random(0.5,1.0), random(2,4) , random(0,5) , random(0,180))
			TNT1 AA 0 A_SpawnItemEx ("buckshot_spark2", 0, 0, 0, /*f*/random(0.5,1.0), random(2,4) , random(0,5) , random(0,180))
			TNT1 AA 0 A_SpawnItemEx ("buckshot_smoke", 0, 0, 0,  0, /*f*/random(-0.3,0.3) , /*f*/random(0,0.35) , random(0,180))
			TNT1 A 0 A_Jump(255, "Puff1","Puff2","Puff3","Puff4")
		Puff1:
			IPF2 AAA 1 bright //A_SetScale (scaleX * 0.9 ,scaleY * 0.9)
			stop
		Puff2:
			IPF2 BBB 1 bright //A_SetScale (scaleX * 0.9 ,scaleY * 0.9)
			stop
		Puff3:
			IPF2 CCC 1 bright //A_SetScale (scaleX * 0.9 ,scaleY * 0.9)
			stop
		Puff4:
			IPF2 DDD 1 bright //A_SetScale (scaleX * 0.9 ,scaleY * 0.9)
			stop
			
		xdeath:
			TNT1 A 0
			stop
	}
}

actor buckshot_flare {
	scale 0.16
	alpha 1.0
	renderstyle add
	+NOINTERACTION
	+FORCEXYBILLBOARD
	+NOTELEPORT
	+CLIENTSIDEONLY
	
	states {
		spawn:
			LEYS O 3
		spawnloop:
			LEYS O 1 bright A_FadeOut(0.25)
			loop
	}
}

actor buckshot_spark {
	radius 2
	height 2
	alpha 1
	scale 0.024
	gravity 0.4
	renderstyle add
	+NOTELEPORT
	+FLOORCLIP
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	bouncetype "doom"
	bouncefactor 0.2
	states{
		spawn:
			SPRK AAA 2 bright A_ScaleVelocity(0.9)
		spawnloop:
			TNT1 A 0 A_ScaleVelocity(0.9)
			SPRK A 1 bright A_FadeOut(0.1)
			loop
	}
}

actor buckshot_spark2 : buckshot_spark {
	scale 0.028
	gravity 0.3
	states{
		spawn:
			SPRK CCCCC 2 bright A_ScaleVelocity(0.9) 
		spawnloop:
			TNT1 A 0 A_ScaleVelocity(0.9)
			SPRK C 1 bright A_FadeOut(0.1)
			loop
	}
}

actor buckshot_smoke {
	scale 0.1
	alpha 0.45
	renderstyle add
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 3
			TNT1 A 0 A_Jump(255,"smoek1","smoek2","smoek3","smoek4","smoek5","smoek6")
		smoek1:
			TNT1 A 0 //A_SetScale(ScaleX * 1.02, ScaleY * 1.02)
			SMK1 A 2 A_Fadeout(0.015)
			loop
		smoek2:
			TNT1 A 0 //A_SetScale(ScaleX * 1.02, ScaleY * 1.02)
			SMK1 B 2 A_Fadeout(0.015)
			loop
		smoek3:
			TNT1 A 0 //A_SetScale(ScaleX * 1.02, ScaleY * 1.02)
			SMK1 C 2 A_Fadeout(0.015)
			loop
		smoek4:
			TNT1 A 0 //A_SetScale(ScaleX * 1.02, ScaleY * 1.02)
			SMK1 D 2 A_Fadeout(0.015)
			loop
		smoek5:
			TNT1 A 0 //A_SetScale(ScaleX * 1.02, ScaleY * 1.02)
			SMK1 E 2 A_Fadeout(0.015)
			loop
		smoek6:
			TNT1 A 0 //A_SetScale(ScaleX * 1.02, ScaleY * 1.02)
			SMK1 F 2 A_Fadeout(0.015)
			loop
	}
}


actor regshell_casing {
	scale 0.09
	radius 2
	height 2
	speed 6
	mass 4
	bouncefactor 0.5
	PROJECTILE
	+DOOMBOUNCE
	+NODROPOFF
	+FORCEXYBILLBOARD
	+NOTELEPORT
	+FLOORCLIP
	-NOGRAVITY
	-NOBLOCKMAP
	+CLIENTSIDEONLY
	seesound "casings/hp_shell"
	deathsound "casings/hp_shell"
	states{
		spawn:
			SHCS ABCDEFG 2
			loop
		death:
			NULL A 0 A_Jump(255, "pos1", "pos2", "pos3")
			NULL A 0
		pos1:
			SHCS C 400
			SHCS CCCCCCCCCC 1 A_FadeOut(0.1)
			stop
		pos2:
			SHCS D 400
			SHCS DDDDDDDDDD 1 A_FadeOut(0.1)
			stop
		pos3:
			SHCS G 400
			SHCS GGGGGGGGGG 1 A_FadeOut(0.1)
			stop
			
	}
}

actor regshell_spawner {
	speed 15
	PROJECTILE
	+NOCLIP
	+CLIENTSIDEONLY
	states{
		spawn:
			NULL A 0
			NULL A 1 A_SpawnItemEx("regshell_casing", -7, 9, 0, 0, random(3,4), random(1,2), 0, SXF_TRANSFERPOINTERS) 
			stop
	}

}