
//Dusk damage chart (type: Dmg)
//SP: 300
//MP: 75

const int SwordDmg = 75;
const int SwordRange = 116;
const int SwordFullDmg = 200;
const int SwordFullRange = 150;


//Made by Hatori Hanzo. (I hope you get the movie reference)
ACTOR Dusk_Sword : DuskWeapon
{
	Weapon.SelectionOrder 90
Weapon.Slotnumber 1
//	Weapon.SisterWeapon Dusk_Sword_Fastfire

	+WEAPON.NOALERT
	+WEAPON.MELEEWEAPON

	Weapon.UpSound "sword/raise"
	Inventory.PickupMessage "SWORD_PICK"
	Obituary "$SWORD_OB"
	Tag "Sword"
	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")

		W11C A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
	Deselect:
    TNT1 A 0 A_TakeInventory("SetWeaponMemory",50)
    TNT1 A 0 A_GiveInventory("SetWeaponMemory",2)
	DeselectLoop:
		TST1 AAA 0 A_Lower
		TST1 A 1 A_Lower
		Loop
	Select:
		TNT1 A 0 A_SetCrosshair(10)
    TNT1 A 0 A_TakeInventory("SetWeaponActual",50)
    TNT1 A 0 A_GiveInventory("SetWeaponActual",2)
//		TNT1 A 4 A_WeaponReady//(WRF_NOFIRE)
		W11A ABCDEFGHIJKLM 1 A_WeaponReady//(WRF_NOFIRE)
		Goto Ready


	Reload://Weapon spin
	TNT1 A 0 A_PlaySound("sickles/fire")
		W11D A 1 A_WeaponReady //(WRF_ALLOWRELOAD)
		W11D BCDE 1 A_WeaponReady (WRF_NOBOB)
		W11D FG 1 A_WeaponReady (WRF_NOBOB|WRF_ALLOWRELOAD)
		W11D HIJKLMNOPQRSTUVWX 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready





//Powered up fire
	Fire:
		TNT1 A 0 A_JumpIfHealthLower(100,"Fire_99")
//		W11C A 3 A_WeaponReady(WRF_NOFIRE)
//		TNT1 A 0 A_Refire(1)
//	Goto Fire99
		TNT1 A 0 A_PlayWeaponSound("sword/altload")
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",31,"Fire_Stacked2")
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",1,"Fire_Stacked1")
		W11G A 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)//If you don't hold altfire, it goes back into fire.
		Goto Fire_99
		W11G B 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99
		W11G C 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99
		W11G D 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99

		W11G EF 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99

		W11G GH 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99
		
		W11G IJK 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99
		W11G LMNO 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire("Fire100Hold")
		Goto Fire100End




	Fire_Stacked1:
		W11G A 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)//If you don't hold altfire, it goes back into fire.
		Goto Fire_99
		W11G C 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99
		W11G E 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99
		W11G G 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99

		W11G IK 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99

		W11G MO 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire("Fire100Hold")
		Goto Fire100End




	Fire_Stacked2:
		W11G A 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)//If you don't hold altfire, it goes back into fire.
		Goto Fire_99
		W11G E 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99
		W11G I 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire_99

		W11G M 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire("Fire100Hold")
		Goto Fire100End





	Fire100Hold:
		TNT1 A 0 A_JumpIfHealthLower(100,"Fire100End")
		W11H ABC 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire100End
		W11H DEF 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire100End
		TNT1 A 0 A_JumpIfHealthLower(100,"Fire100End")
		W11H GHI 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto Fire100End
		W11H JKL 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire("Fire100Hold")
		Goto Fire100End




	Fire100End:
		TNT1 A 0 A_Gunflash("Flash100")
	//TNT1 A 0 A_PlaySound("sword/altfire")
		TNT1 A 0 A_PlayWeaponSound("sword/fire")
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",1,"Fire100End_Stacked")
		W11I ABCDEFGHIJKL 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W11I MNOPQRSTUVW 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W11I XYZ 1 A_WeaponReady (WRF_ALLOWRELOAD)
		W11J ABCD 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready
		

	Fire100End_Stacked:
		W11I ABCDEFGH 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W11I IJKL 1 BRIGHT A_WeaponReady (WRF_ALLOWRELOAD)
		W11I MNOPQRSTUVWXYZ 1 A_WeaponReady (WRF_ALLOWRELOAD)
		W11J ABCD 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready


		
	
	
		

//Normal fire if below 100 hp		
	Fire_99:
		TNT1 A 0 A_Gunflash
		TNT1 A 0 A_JumpIfInventory("Weapon_Fireleft", 1, "Fire_99_Left")	 

		TNT1 A 0 A_GiveInventory("Weapon_Fireleft", 1)
		Goto Fire_99_Continue

	Fire_99_Left:
        TNT1 A 0 A_TakeInventory("Weapon_Fireleft", 2)
		Goto Fire_99_Continue



	Fire_99_Continue:
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",31,"Fire_99_Continue_Stacked2")
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",1,"Fire_99_Continue_Stacked1")
			W11F A 0 A_JumpIfInventory("Weapon_Fireleft", 1, 2)
			W11E A 0
		"####" ABCDEFGHIJKLMNOPQRSTU 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		"####" VWXYZ 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready


	Fire_99_Continue_Stacked1:
			W11F A 0 A_JumpIfInventory("Weapon_Fireleft", 1, 2)
			W11E A 0
		"####" ABCDEFGHIJK 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		"####" LMNOPQRSTUVWXYZ 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready


	Fire_99_Continue_Stacked2:
			W11F A 0 A_JumpIfInventory("Weapon_Fireleft", 1, 2)
			W11E A 0
		"####" ABCDEF 1 A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		"####" GHIJKLMNOPQRSTUVWXYZ 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready









//Altfire cover if armor is above 50.
    AltFire:
	  TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("MultiplayerCheck",0,0,0,0) == 2,"Ready")
		W11C A 0 A_JumpIfInventory("BasicArmor", 50, 2)
		W11C A 1 A_WeaponReady(WRF_NOFIRE|WRF_ALLOWZOOM|WRF_ALLOWRELOAD)
			Goto Ready
	TNT1 A 0 A_TakeInventory("BasicArmor",1)
		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11K A 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
//		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11K B 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
//		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11K C 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire("AltFireCoverLoop")
		Goto AltFireCoverEnd
			

	AltFireCoverLoop:
		W11C A 0 A_JumpIfInventory("BasicArmor", 50, 2)
		W11C A 0 A_Refire("AltFireCoverEnd")//A_WeaponReady(WRF_NOFIRE|WRF_ALLOWZOOM|WRF_ALLOWRELOAD)
			Goto Ready
		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L A 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
//		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L B 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
//		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L C 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto AltFireCoverEnd

		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L D 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
//		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L E 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
//		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L F 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto AltFireCoverEnd

		W11C A 0 A_JumpIfInventory("BasicArmor", 50, 2)
		W11C A 0 A_Refire("AltFireCoverEnd")//A_WeaponReady(WRF_NOFIRE|WRF_ALLOWZOOM|WRF_ALLOWRELOAD)
			Goto Ready

	TNT1 A 0 A_TakeInventory("BasicArmor",1)
		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L G 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
//		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L H 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
//		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L I 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire(1)
		Goto AltFireCoverEnd

		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L J 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
//		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L K 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
//		TNT1 A 0 A_Gunflash("FlashDeflect")
		W11L L 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire("AltFireCoverLoop")
		Goto AltFireCoverEnd			



	AltFireCoverEnd:
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",1,"AltFireCoverEnd_Stacked")
		W11M ABCDEFGH 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W11M IJKLMNOPQR 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready	

	AltFireCoverEnd_Stacked:
		W11M ABCD 1 BRIGHT A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		W11M EFGH 1 BRIGHT A_WeaponReady (WRF_ALLOWRELOAD)
		W11M IJKLMNOPQR 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready	



	



	Flash:
		W11G A 0 A_CustomPunch(SwordDmg, TRUE, 0, "SwordPuff", SwordFullRange)//A_Punch
		TNT1 A 3 A_PlayWeaponSound("sword/fire")
		Goto LightDone	

	Flash100:
		W11G A 0 A_CustomPunch(SwordFullDmg, TRUE, 0, "AltSwordPuff", SwordFullRange)//A_Punch
		TNT1 A 3 A_PlayWeaponSound("sword/fire")
		Goto LightDone	


	FlashDeflect:
	  TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("MultiplayerCheck",0,0,0,0) == 2,"Flash_NoDeflectionMode")
TNT1 A 0 A_JumpIf(CallACS("SicklesType")==3, "Flash_ModernGZDmode")
TNT1 A 0 A_JumpIf(CallACS("SicklesType")==2, "Flash_Dooskmode")
TNT1 A 0 A_JumpIf(CallACS("SicklesType")==1, "Flash_Vanillamode")




	Flash_NoActorMode:
		TNT1 A 1 //A_SpawnItemEx("Sickles_BlockProjectileOnly",40,0,0,  0,0,0  ,0,SXF_NOCHECKPOSITION|SXF_SETMASTER)
		Goto LightDone	

	Flash_NoDeflectionMode:
		TNT1 A 1 A_SpawnItemEx("Sickles_BlockProjectileOnly",40,0,0,  0,0,0  ,0,SXF_NOCHECKPOSITION|SXF_SETMASTER)
		Goto LightDone	

	Flash_VanillaMode:
		TNT1 A 1 A_SpawnItemEx("Sickles_BlockProjectileAttacks",40,0,0,  0,0,0  ,0,SXF_NOCHECKPOSITION|SXF_SETMASTER)
		Goto LightDone	

	Flash_DooskMode:
		TNT1 A 1 A_SpawnItemEx("Sickles_BlockDooskProjectileAttacks",40,0,0,  0,0,0  ,0,SXF_NOCHECKPOSITION|SXF_SETMASTER)
		Goto LightDone	

	Flash_ModernGZDMode:
		TNT1 A 1 A_SpawnItemEx("Sickles_AimReflectProjectileAttacks",40,0,0,  0,0,0  ,0,SXF_NOCHECKPOSITION|SXF_SETMASTER)
		Goto LightDone



	Spawn:
		W01Z A -1
		Stop
	}
}



