//   GOLAM GW35B ASSAULT PISTOL	
/////////////////

actor GolamReloadCount : Inventory {}

actor golampistol : weapon replaces Pistol{
	Tag "Golam Pistol"

	weapon.selectionorder 130
	inventory.pickupsound "weapons/gp_slide"
	inventory.pickupmessage "Golam GW35B Assault Pistol"

	scale 0.31
	weapon.ammotype "golamclip"
	weapon.ammotype2 "pistol_ammo"
	weapon.ammouse 0//1
	weapon.ammouse2 0
	weapon.ammogive1 0
	weapon.ammogive2 6
	weapon.kickback 120
	Weapon.preferredSkin "PistolSkin"
	//weapon.bobstyle inverse
	//weapon.bobrangeX 0.4
	//weapon.bobrangeY 0.75
	//weapon.bobspeed 2.5
	+AMMO_OPTIONAL
	//+NOAUTOFIRE
	+NOALERT
	+WEAPON.NOAUTOAIM
	+INVENTORY.UNDROPPABLE
	
	states{
		spawn:
			GAPW A -1
    		loop

		ready:
			//TNT1 A 0 A_SetCrosshair(10)
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory",11,"GrenadeEnd")
			GAPU F 1 A_PlaySound("weapons/gp_select", CHAN_WEAPON)
			GAPU EDCBA 1
			NULL A 0 A_TakeInventory("xhair_switch",1)
			NULL A 0 A_GiveInventory("xhair_switch",1)

			GAPI 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("golamclip", 9, 2)
			NULL A 0 A_JumpIfInventory("ReloadingWeapon", 1, "Reload")
			GAPI A 1 A_WeaponReady
			goto ready+10

  		deselect:
			NULL A 0 A_TakeInventory("xhair_switch",1)
			NULL A 0 A_TakeInventory("pistol_acc",80)
			GAPI A 1 A_PlaySound("weapons/gp_deselect", CHAN_WEAPON)
			GAPU ABCDEFXXXXXX 1
			GAPI A 1 A_Lower 
			goto deselect+14
  		select:
			NULL A 0 SetPlayerProperty(0,1,2)
			NULL A 0 A_Raise
			Goto Select+1

		/////
		Sprint:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SprStart")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto ready+10
		SprStart:
			TNT1 A 0 ACS_ExecuteAlways(Player_ChangeSpeed,0,200,0,0)
			TNT1 A 0 A_PlaySound("sfx/sprintstart",CHAN_AUTO)
			TNT1 A 0 A_SetBlend("49 99 0",0.4,15)
			TNT1 A 0 A_Recoil(-15)
			GASS ABCDE 1
			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:
			//GASX ABCDEF 1
			GASS E 1 Offset(-4,33)
			//GASS E 1 Offset(-27,36)
			GASS E 1 Offset(-24,39)
			GASS E 1 Offset(-30,44)
			GASS E 1 Offset(-33,47)
			GASS E 1 Offset(-34,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:
			//GASX FEDCBA 1
			GASS E 1 Offset(-34,50)
			//GASS E 1 Offset(-43,47)
			GASS E 1 Offset(-30,44)
			GASS E 1 Offset(-24,39)
			GASS E 1 Offset(-17,36)
			GASS E 1 Offset(-4,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:
			//GASX GHIJKL 1
			GASS E 1 Offset(4,33)
			//GASS E 1 Offset(27,36)
			GASS E 1 Offset(24,39)
			GASS E 1 Offset(30,44)
			GASS E 1 Offset(33,47)
			GASS E 1 Offset(34,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:
			//GASX LKJIHG 1
			GASS E 1 Offset(34,50)
			//GASS E 1 Offset(33,47)
			GASS E 1 Offset(30,44)
			GASS E 1 Offset(24,39)
			GASS E 1 Offset(17,36)
			GASS E 1 Offset(04,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)
			GASS EDCBA 1
			goto ready+10

		Fire:
			TNT1 A 0 A_JumpIfInventory("golamclip", 1, 3)
			GAPO A 2 A_PlaySound("weapons/noammo", CHAN_WEAPON)
			GAPI A 4
			goto ready+8
			
			TNT1 A 0 A_TakeInventory("golamclip", 1)

			TNT1 A 0 A_PlayWeaponSound("weapons/gp_fire")
			TNT1 A 0 A_AlertMonsters
			TNT1 A 0 A_GunFlash	
			
			TNT1 A 0 A_JumpIfInventory("pistol_acc", 40, "FrAcc8")
			TNT1 A 0 A_JumpIfInventory("pistol_acc", 35, "FrAcc7")
			TNT1 A 0 A_JumpIfInventory("pistol_acc", 30, "FrAcc6")
			TNT1 A 0 A_JumpIfInventory("pistol_acc", 25, "FrAcc5")
			TNT1 A 0 A_JumpIfInventory("pistol_acc", 20, "FrAcc4")
			TNT1 A 0 A_JumpIfInventory("pistol_acc", 15, "FrAcc3")
			TNT1 A 0 A_JumpIfInventory("pistol_acc", 10, "FrAcc2")
			TNT1 A 0 A_JumpIfInventory("pistol_acc", 5, "FrAcc1")			
		FrAcc0:
			TNT1 A 1 A_FireBullets (2,1,-1,65+random(0,8)*2,"pistol_impact",FBF_NORANDOM | FBF_USEAMMO)
			TNT1 A 0 A_GiveInventory("pistol_acc", 22)
			goto FireLast
		FrAcc1:
			TNT1 A 1 A_FireBullets (2,2,-1,65+random(0,8)*2,"pistol_impact",FBF_NORANDOM | FBF_USEAMMO)
			TNT1 A 0 A_GiveInventory("pistol_acc", 22)
			goto FireLast
		FrAcc2:
			TNT1 A 1 A_FireBullets (3,2,-1,65+random(0,8)*2,"pistol_impact",FBF_NORANDOM | FBF_USEAMMO)
			TNT1 A 0 A_GiveInventory("pistol_acc", 22)
			goto FireLast
		FrAcc3:
			TNT1 A 1 A_FireBullets (3,3,-1,65+random(0,8)*2,"pistol_impact",FBF_NORANDOM | FBF_USEAMMO)
			TNT1 A 0 A_GiveInventory("pistol_acc", 22)
			goto FireLast
		FrAcc4:
			TNT1 A 1 A_FireBullets (4,3,-1,65+random(0,8)*2,"pistol_impact",FBF_NORANDOM | FBF_USEAMMO)
			TNT1 A 0 A_GiveInventory("pistol_acc", 22)
			goto FireLast
		FrAcc5:
			TNT1 A 1 A_FireBullets (4,4,-1,65+random(0,8)*2,"pistol_impact",FBF_NORANDOM | FBF_USEAMMO)
			TNT1 A 0 A_GiveInventory("pistol_acc", 22)
			goto FireLast
		FrAcc6:
			TNT1 A 1 A_FireBullets (5,4,-1,65+random(0,8)*2,"pistol_impact",FBF_NORANDOM | FBF_USEAMMO)
			TNT1 A 0 A_GiveInventory("pistol_acc", 22)
			goto FireLast
		FrAcc7:
			TNT1 A 1 A_FireBullets (5,5,-1,65+random(0,8)*2,"pistol_impact",FBF_NORANDOM | FBF_USEAMMO)
			TNT1 A 0 A_GiveInventory("pistol_acc", 22)
			goto FireLast
		FrAcc8:
			TNT1 A 1 A_FireBullets (6,5,-1,65+random(0,8)*2,"pistol_impact",FBF_NORANDOM | FBF_USEAMMO)
			TNT1 A 0 A_GiveInventory("pistol_acc", 22)
			goto FireLast
	
			
			
		FireLast:
			//TNT1 A 0 ACS_ExecuteAlways(Weapon_Recoil,0,15,random(-13,13),0)
			GAPI D 1 A_FireCustomMissile("pcasing_spawner",0,0,0,8,0)
			GAPI DCB 1
    	    GAPI A 1 A_Refire
			goto ready+8
		
		Hold:
			GAPI A 1 A_WeaponReady
			GAPI A 0 A_Refire
			goto ready+8
		
		Flash:
			NULL A 0 A_Jump(255, "FireF1", "FireF2", "FireF3")
		FireF1:
			GAPF A 1 bright A_Light1
			NULL A 1 A_Light0
			stop
		FireF2:
			GAPF B 1 bright A_Light1
			NULL A 1 A_Light0
			stop
		FireF3:
			GAPF C 1 bright A_Light1
			NULL A 1 A_Light0
			stop
		
		Reload:
			GAPI A 0 A_JumpIfInventory("pistol_ammo", 1, 1)
			goto ready+8
			
			TNT1 A 0 A_GiveInventory("pistol_acc", 45)
			TNT1 A 0 A_GiveInventory("xhair_hold",1)
			GAPR ABC 1
			GAPR D 1 A_PlaySound("weapons/gp_clipout", CHAN_WEAPON)	
			GAPR EFG 1
			GAPR H 10
			GAPR I 1
			GAPR J 1 A_PlaySound("weapons/gp_clipin", CHAN_WEAPON)
			GAPR K 1
			GAPR L 3
			GAPR MN 1
			GAPR O 1 A_PlaySound("weapons/gp_clipin2", CHAN_WEAPON)
		Reload_FillClip:
			NULL A 0 A_TakeInventory("pistol_ammo",1)
			NULL A 0 A_GiveInventory("golamclip",1)
			NULL A 0 A_JumpIfInventory("golamclip",9,"ReloadFinish")
			NULL A 0 A_JumpIfInventory("pistol_ammo",1,"Reload_FillClip")
		ReloadFinish:
			TNT1 A 0 A_GiveInventory("GolamReloadCount", 1)
			GAPR P 1
			GAPR Q 1
			GAPR R 3
			TNT1 A 0 A_TakeInventory("xhair_hold",1)
			GAPR PST 1
			GAPR U 1 A_PlaySound("weapons/gp_slide", CHAN_WEAPON) 
			GAPR VWXY 1
			goto ready+8
			
			
		Grenade:
			TNT1 A 0 A_JumpIfInventory("grenades", 1, 2)
			TNT1 A 0
			goto ready+8
			GAPU ABCDEFG 1
			TNT1 A 0 A_GiveInventory("gtoss_weaponmemory", 11)
			TNT1 A 0 A_SelectWeapon("grenade_toss")
			goto deselect+14
		GrenadeEnd:
			TNT1 A 0 A_TakeInventory("gtoss_weaponmemory",99)
			GAPU GFEDCBA 1
			goto ready+8
		AltFire:
			GAPM B 1 A_Recoil(-6)
			NULL A 0 A_PlayWeaponSound("sfx/meleeswing")
			GAPM DFH 1
			GAPM J 9 A_CustomPunch ((164+random(1,32)), 1 , 0 , "meleepuff",88)
			GAPM IHGFE 1
			TNT1 A 2
			GAPM DCBA 1	
			goto ready+8
		
	}
}


actor golamclip : Ammo{
	Inventory.MaxAmount 9
	+INVENTORY.IGNORESKILL
}

actor pistol_acc : Inventory {
	-INVBAR
	Inventory.icon "CBALH0"
	Inventory.Amount 1
	Inventory.MaxAmount 45
}

actor pistol_impact{		
	Radius 1
	Height 1
	Alpha 1
	DamageType pistol_damage
	RenderStyle ADD
	Scale 0.38
	+NOGRAVITY
	+NOBLOCKMAP
	+FLOORCLIP
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+NOEXTREMEDEATH
	+NOINTERACTION
	+PUFFONACTORS
	+PUFFGETSOWNER
	+CLIENTSIDEONLY
	States{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_Explode(28,20,0)
			TNT1 A 0 A_PlaySound("sfx/bulletric")
			TNT1 A 0 A_SpawnItemEx ("pistimp_flash", 0, 0, 0,  0,0,0, 0)
			TNT1 AAAAAA 0 A_SpawnItemEx ("pistimp_spark", 0, 0, 0, /*f*/random(0.5,1.0), random(1,3) , random(0,4) , random(0,180))
			TNT1 AAAA 0 A_SpawnItemEx ("pistimp_spark2", 0, 0, 0, /*f*/random(0.5,1.0), random(1,3) , random(0,4) , random(0,180))
			TNT1 AAAA 0 A_SpawnItemEx ("pistimp_smoke", 0, 0, 0,  0, /*f*/random(-0.35,0.35) , /*f*/random(0,0.45) , random(0,180))
			TNT1 A 0 A_Jump(255, "Puff1","Puff2","Puff3","Puff4","Puff5")
		Puff1:
			EXP0 AABCDEFGH 1 bright //A_SetScale (scaleX * 1.06 ,scaleY * 1.06)
			stop
		Puff2:
			EXP6 AABCDEFGH 1 bright //A_SetScale (scaleX * 1.06 ,scaleY * 1.06)
			stop
		Puff3:
			EXP7 AABCDEFGH 1 bright //A_SetScale (scaleX * 1.06 ,scaleY * 1.06)
			stop
		Puff4:
			EXP8 AABCDEFGH 1 bright //A_SetScale (scaleX * 1.06 ,scaleY * 1.06)
			stop
		Puff5:
			EXP9 AABCDEFGH 1 bright //A_SetScale (scaleX * 1.06 ,scaleY * 1.06) 
			stop
			
		xdeath:
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx ("pistimp_flash", 0, 0, 0,  0,0,0, 0)
			TNT1 A 0 A_Jump(100, "Puff1","Puff2","Puff3","Puff4","Puff5")
		Puff1:
			EXP0 AABCDEFGH 1 bright //A_SetScale (scaleX * 1.06 ,scaleY * 1.06)
			stop
		Puff2:
			EXP6 AABCDEFGH 1 bright //A_SetScale (scaleX * 1.06 ,scaleY * 1.06)
			stop
		Puff3:
			EXP7 AABCDEFGH 1 bright //A_SetScale (scaleX * 1.06 ,scaleY * 1.06)
			stop
		Puff4:
			EXP8 AABCDEFGH 1 bright //A_SetScale (scaleX * 1.06 ,scaleY * 1.06)
			stop
		Puff5:
			EXP9 AABCDEFGH 1 bright //A_SetScale (scaleX * 1.06 ,scaleY * 1.06) 
			stop
	}
}

actor pistol_impactB : pistol_impact {
	DamageType normal
	States{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_PlaySound("sfx/bulletric")
			TNT1 A 0 A_SpawnItemEx ("pistimp_flash", 0, 0, 0,  0,0,0, 0)
			TNT1 AAAAAA 0 A_SpawnItemEx ("pistimp_spark", 0, 0, 0, /*f*/random(0.5,1.0), random(1,3) , random(0,4) , random(0,180))
			TNT1 AAAA 0 A_SpawnItemEx ("pistimp_spark2", 0, 0, 0, /*f*/random(0.5,1.0), random(1,3) , random(0,4) , random(0,180))
			TNT1 AAAA 0 A_SpawnItemEx ("pistimp_smoke", 0, 0, 0,  0, /*f*/random(-0.35,0.35) , /*f*/random(0,0.45) , random(0,180))
			TNT1 A 0 A_Jump(255, "Puff1","Puff2","Puff3","Puff4","Puff5")
	}
}

actor pistimp_flash {
	scale 0.4
	alpha 1.0
	renderstyle add
	+FORCEXYBILLBOARD
	+NOTELEPORT
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0 A_Jump(255,"flsh1","flsh2","flsh3","flsh4")
		flsh1:
			IPF3 A 2 bright
			stop
		flsh2:
			IPF3 B 2 bright
			stop
		flsh3:
			IPF3 C 2 bright
			stop
		flsh4:
			IPF3 D 2 bright
			stop
	
	}
}

actor pistimp_spark {
	radius 2
	height 2
	alpha 1
	scale 0.025
	gravity 0.4
	renderstyle add
	+NOTELEPORT
	+FLOORCLIP
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	bouncetype "doom"
	bouncefactor 0.2
	states{
		spawn:
			SPRK A 10 bright
		spawnloop:
			SPRK A 1 bright A_FadeOut(0.1)
			loop
	}
}

actor pistimp_spark2 : pistimp_spark {
	scale 0.04
	gravity 0.3
	states{
		spawn:
			SPRK C 15 bright
		spawnloop:
			SPRK C 1 bright A_FadeOut(0.1)
			loop
	}
}


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



actor pistol_casing {
	scale 0.13
	radius 2
	height 2
	speed 6
	mass 4
	bouncefactor 0.6
	PROJECTILE
	+DOOMBOUNCE
	+NODROPOFF
	+FORCEXYBILLBOARD
	+NOTELEPORT
	+FLOORCLIP
	-NOGRAVITY
	-NOBLOCKMAP
	+CLIENTSIDEONLY
	seesound "casings/gp_casing"
	states{
		spawn:
			PBCS ABCDEF 2
			loop
		death:
			NULL A 0 A_Jump(255, "pos1", "pos2", "pos3")
			NULL A 0
		pos1:
			PBCS F 400
			PBCS FFFFFFFFFF 1 A_FadeOut(0.1)
			stop
		pos2:
			PBCS C 400
			PBCS CCCCCCCCCC 1 A_FadeOut(0.1)
			stop
		pos3:
			PBCS E 400
			PBCS EEEEEEEEEE 1 A_FadeOut(0.1)
			stop
			
	}
}

actor pcasing_spawner {
	speed 15
	PROJECTILE
	+NOCLIP
	+CLIENTSIDEONLY
	states{
		spawn:
			NULL A 0
			NULL A 1 A_SpawnItemEx("pistol_casing", 0, 10, 3, 1, random(4,5), random(1,2), 0, SXF_TRANSFERPOINTERS) 
			stop
	}

}