
//Dusk damage chart (type: Dmg)
//SP: 25
//MP: 20


//Better than nothing. Give the man a gun and he's Superman.
ACTOR Dusk_Pistol_newammo : DuskWeapon //replaces pistol
{
	+POWERED_UP 
	Weapon.SisterWeapon Dusk_Pistol

	Weapon.SelectionOrder 80
Weapon.Slotnumber 2
//	Weapon.SisterWeapon Dusk_Pistol_Fastfire

	Weapon.AmmoUse 1
	Weapon.AmmoGive 12//20
	Weapon.AmmoType "Dusk_Wep2Ammo"
	Weapon.UpSound "Pistol/raise"

	DamageType "PistolShot"
	Inventory.PickupMessage "$PIST_PICK"
	Obituary "$PIST1_OB"
	Tag "Pistol"
	States
	{
	Ready:
TNT1 A 0 A_JumpIfInventory("Doosk_ExplosiveBarrelWeapon",1,"Select_Barrel")
TNT1 A 0 A_JumpIfInventory("Doosk_HereticBarrelWeapon",1,"Select_HereticBarrel")
TNT1 A 0 A_JumpIfInventory("Doosk_SoapWeapon",1,"Select_Soap")

		W02C A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
	Deselect:
    TNT1 A 0 A_TakeInventory("SetWeaponMemory",50)
    TNT1 A 0 A_GiveInventory("SetWeaponMemory",3)
	DeselectLoop:
		TST1 AAA 0 A_Lower
		TST1 A 1 A_Lower
		Loop
	Select:
		TNT1 A 0 A_SetCrosshair(11)
    TNT1 A 0 A_TakeInventory("SetWeaponActual",50)
    TNT1 A 0 A_GiveInventory("SetWeaponActual",3)
//		TNT1 A 0 A_WeaponReady(WRF_NOFIRE)
		W02A ABCDEFGHIJKLM 1 A_WeaponReady//(WRF_NOFIRE)
		Goto Ready


	Reload://Weapon spin
	TNT1 A 0 A_PlaySound("sickles/fire")
		W01G A 0 A_CustomPunch(2 * random(1, 10), TRUE, 0, "Meleepuff")

		W02D ABCDE 1 A_WeaponReady //(WRF_ALLOWRELOAD)
		W02D FGHIJKLMNOPQRSTUVWXYZ 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready
		


	Fire:
		W12F A 0 A_Gunflash		TNT1 A 0 A_GiveInventory("Player_WeaponShot",1)

	  TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("MultiplayerCheck",0,0,0,0) == 2,2)
TNT1 A 0 A_JumpIf(CallACS("derekgun_type")==2, "Fire_NormalSlow")//If mutator is detected, jumps into old mortar.
TNT1 A 0 A_JumpIf(CallACS("derekgun_type")==1, "Fire_Derek")//If mutator is detected, jumps into old mortar.

		TNT1 A 0 A_PlaySound("Pistol/fire", CHAN_WEAPON)

TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",31,	"Fire_Stacked2")
		W02F ABCD 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)

TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",1,	"Fire_Stacked1")
		W02F EFGHIJ 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W02F KL 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready
		

	Fire_Stacked1:
		W02F E 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W02F FGHIJKL 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready


	Fire_Stacked2:
		W02F ABC 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W02F D 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W02F EFGHIJKL 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready
		


	Fire_NormalSlow:
		TNT1 A 0 A_PlaySound("Pistol/fire", CHAN_WEAPON)
Goto Fire_Derek_Continue

	Fire_derek:
		TNT1 A 0 A_PlaySound("sounds/derekbum_shot", CHAN_WEAPON)

Fire_Derek_Continue:
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",31,	"Fire_Stacked2_derek")
		W02F ABCD 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)

TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",1,	"Fire_Stacked1_derek")
		W02F EFGHIJKL 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W02C AA 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
TNT1 A 0 A_JumpIf(CallACS("derekgun_type")==2, "Ready")
		W02C AAAAAAAAAAAA 1 A_WeaponReady (WRF_ALLOWRELOAD)
		PISG A 0 A_PlaySound("sounds/derekbum_end")
		Goto Ready
		

	Fire_Stacked1_derek:
		W02F EFG 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W02F HIJKL 1 A_WeaponReady (WRF_ALLOWRELOAD)
TNT1 A 0 A_JumpIf(CallACS("derekgun_type")==2, "Ready")
		W02C AAAAAAAAAAAAAA 1 A_WeaponReady (WRF_ALLOWRELOAD)
		PISG A 0 A_PlaySound("sounds/derekbum_end")
		Goto Ready


	Fire_Stacked2_derek:
		W02F ABC 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W02F DE 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W02F FGHIJKL 1 A_WeaponReady (WRF_ALLOWRELOAD)
TNT1 A 0 A_JumpIf(CallACS("derekgun_type")==2, "Ready")
		W02C AAAAAAAAAAAAAA 1 A_WeaponReady (WRF_ALLOWRELOAD)
		PISG A 0 A_PlaySound("sounds/derekbum_end")
		Goto Ready


		




//	TNT1 A 0 A_JumpIf(CallACS("DamageType")==1, "DuskDamageFlash")
	Flash:
		TNT1 A 0 A_FireBullets (PistolSpreadHorz, PistolSpreadVert, -1, PistolDmg, "WeaponPuff_Pistol")
	FlashContinue:
//		TNT1 A 0 A_PlaySound("Pistol/fire", CHAN_WEAPON)
	TNT1 A 0 ACS_NamedExecuteAlways("Weapon_Recoil", 0, 4, 0, 0)
 

	TNT1 A 1 A_JumpIf(CallACS("CasingsType")==1, "CasingSpawner")
		C02A ABC 1 A_Light2
		C02A DEFG 1 A_Light1
		TNT1 A 0 A_Light0
		C02A HIJKLMNOP 1 
Goto LightDone	

	
		
	CasingSpawner:
		TNT1 A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,12,-6)//,-10,0,3,6)//A_SpawnItemEx("PistolCasing",10,-8,28,0,10,10,-45,SXF_TRANSFERPOINTERS)//
	TNT1 A 3 A_Light2
	TNT1 A 4 A_Light1
	TNT1 A 0 A_Light0
		Goto LightDone




	Spawn:
		W02Z A -1
		Stop
	}
}


