/*
CREDITS:
Sprites - NeoWorm, Bethesda (TES: Daggerfall, I think)
Rehand by me.

Sounds:
Swing sounds - Blizzard (Diablo 1)
Up sound, Impacts except flesh ones - Firefly Studios (Stronghold)
Flesh impacts - ?
Grappling attack - Blizzard (Diablo 2)
*/

ACTOR MorningStar : Weapon 24500
{
	//$Category Weapons
	//$Title Morning Star
	//$Sprite MACEX0
	Tag "Morning Star"
	Inventory.PickupSound "misc/w_pkup"
	Inventory.PickupMessage "You got the morning star! Apply directly to the forehead! (1)"
	Obituary "%k applied mace-on directly on %o's forehead."
   	Weapon.UpSound "weapons/maceswingmain"
   	Weapon.SelectionOrder 7
	Weapon.Kickback 100
	Weapon.SlotNumber 1
	/*Weapon.BobStyle InverseSmooth
	Weapon.BobSpeed 1.6
	Weapon.BobRangeY 0.6
	Weapon.BobRangeX 1.2*/
	+NOALERT
	Scale 0.75
	States
	{
		Spawn:
			MACE X -1
			Loop
		Ready:
			MACE A 0 A_TakeInventory("MaceTrigger")
			MACE A 1 A_WeaponReady
			TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
			Loop
		Deselect:
			MACE A 0 A_ZoomFactor(1)
			MACE A 1 A_Lower
			MACE A 0 A_Lower
			Loop
		Select:
			MACE A 1 A_Raise
			MACE A 0 A_Raise
			Loop
		Reload:
			MACS A 0 A_JumpIfInventory("MaceReloading",1,"HeckNope") //What the pope?
			MACS A 0 A_TakeInventory("MaceCounter",1)
			MACE ABCDEFG 1
			TNT1 A 3 A_PlaySound("weapons/macewheeee",5)
			TNT1 A 0 A_PlaySound("weapons/maceloop",6,1,1)
			MACS A 1 A_ZoomFactor(0.99)
			MACS B 1 A_ZoomFactor(0.97)
			MACS C 1 A_ZoomFactor(0.95)
			MACS D 1 A_ZoomFactor(0.92)
			MACS E 1 A_ZoomFactor(0.9)
			MACS F 1 A_ZoomFactor(0.87)
			MACS G 1 A_ZoomFactor(0.85)
		HeckNope:
			MACS A 0 A_GiveInventory("MaceCounter",16)
			MACS A 0 A_GiveInventory("MaceReloading",1)
		CircleLoop:
			MACS H 1 A_TakeInventory("MaceCounter",1)
			MACS H 0 A_SetAngle(Angle+22.5)
			MACS H 0 A_CustomPunch(80,0,0,"MacePuff",175+random(15,-10))
			MACS H 0 A_JumpIfInventory("MaceCounter",1,"CircleLoop")
		Endler:
			TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
			MACS I 1 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE|WRF_NOSWITCH)
			MACS I 0 A_StopSound(6)
			MACS A 0 A_ZoomFactor(1)
			MACS J 1 A_TakeInventory("MaceReloading",1)
			MACS JKL 1
			TNT1 A 10
			MACE GFEDCBA 1
			goto Ready
		Fire:
			MACE ABCDEFG 1
			TNT1 A 3
		FireForEffect:
			MACE A 0 A_TakeInventory("MaceTrigger")
			TNT1 A 0 A_Recoil(-1.25)
			MAC1 AB 1
    		TNT1 A 0 A_PlaySoundEx("weapons/maceswing","SoundSlot6")
			MAC1 C 1 A_PlayWeaponSound("weapons/maceswingmain")
			TNT1 A 0 A_Recoil(-3)
			MAC1 DE 1
			TNT1 F 0 A_CustomPunch(80,0,0,"MacePuff",175+random(15,-10))
			MAC1 FGH 1 A_Recoil(-1)

			TNT1 A 8
			TNT1 A 0 A_ReFire
			TNT1 A 6
			MACE GFEDCBA 1
			goto Ready
		Hold:
		AltHold:
			TNT1 A 0 A_JumpIfInventory("MaceTrigger",1,"FireForEffect")
			TNT1 A 0 A_Jump(255,"HoldSwing1","HoldSwing2","HoldSwing3","HoldSwing4")
		HoldSwing1:
			TNT1 A 0 A_Recoil(-2)
			MAC1 AB 1
    		TNT1 A 0 A_PlaySoundEx("weapons/maceswing","SoundSlot6")
			MAC1 C 1 A_PlayWeaponSound("weapons/maceswingmain")
			TNT1 A 0 A_Recoil(-2)
			MAC1 DE 1
			TNT1 F 0 A_CustomPunch(80,0,0,"MacePuff",175+random(15,-10))
			MAC1 FGH 1 A_Recoil(-1)

			TNT1 A 8
			TNT1 A 0 A_ReFire
			TNT1 A 6
			MACE GFEDCBA 1
			goto Ready
		HoldSwing2:
			TNT1 A 0 A_Recoil(-1)
			MAC2 AB 1
    		TNT1 A 0 A_PlaySoundEx("weapons/maceswing","SoundSlot6")
			MAC2 C 1 A_PlayWeaponSound("weapons/maceswingmain")
			TNT1 A 0 A_Recoil(-3)
			MAC2 DE 1
			TNT1 F 0 A_CustomPunch(80,0,0,"MacePuff",175+random(15,-10))
			MAC2 FGH 1 A_Recoil(-1.5)

			TNT1 A 8
			TNT1 A 0 A_ReFire
			TNT1 A 6
			MACE GFEDCBA 1
			goto Ready
		HoldSwing3:
			TNT1 A 0 A_Recoil(-3)
			MAC3 AB 1
    		TNT1 A 0 A_PlaySoundEx("weapons/maceswing","SoundSlot6")
			MAC3 C 1 A_PlayWeaponSound("weapons/maceswingmain")
			TNT1 A 0 A_Recoil(-1)
			MAC3 DE 1
			TNT1 F 0 A_CustomPunch(80,0,0,"MacePuff",175+random(15,-10))
			MAC3 FGH 1 A_Recoil(-1)

			TNT1 A 8
			TNT1 A 0 A_ReFire
			TNT1 A 6
			MACE GFEDCBA 1
			goto Ready
		HoldSwing4:
			TNT1 A 0 A_Recoil(-2)
			MAC4 AB 1
    		TNT1 A 0 A_PlaySoundEx("weapons/maceswing","SoundSlot6")
			MAC4 C 1 A_PlayWeaponSound("weapons/maceswingmainmain")
			TNT1 A 0 A_Recoil(-1)
			MAC4 DE 1
			TNT1 F 0 A_CustomPunch(80,0,0,"MacePuff",175+random(15,-10))
			MAC4 FGH 1 A_Recoil(-1.5)
			TNT1 A 8
			TNT1 A 0 A_ReFire
			TNT1 A 6
			MACE GFEDCBA 1
			goto Ready
		AltFire:
			MACE A 3 A_PlaySoundEx("Weapons/MaceGrabber","SoundSlot5")
			MACC ABCDEF 1
			MACC G 5 A_FireCustomMissile("GrabberShot")
			MACC FEC 1
			TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
			MACE E 0 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE|WRF_NOSWITCH)
			MACE ACE 1
			MACE E 0 A_GiveInventory("MaceTrigger")
			TNT1 A 15 A_ReFire
			MACE GFEDCBA 1
			Goto Ready
		AltHold:
			TNT1 A 0
			Goto Hold
	}
}

ACTOR MaceTrigger : Inventory
{
   Inventory.MaxAmount 1
}

ACTOR MaceCounter : Inventory
{
   Inventory.MaxAmount 16
}

ACTOR MaceReloading : Inventory
{
   Inventory.MaxAmount 1
}

ACTOR MacePuff : PunchPuff
{ 
   SeeSound "weapons/maceflesh"
   AttackSound "weapons/macewall"
   ActiveSound ""
   States
   {
  Spawn:
    TNT1 A 0 A_PlaySound("weapons/macestruck")
    PUFF AABBCCDD 1 A_FadeOut(0.1)
    stop
  Crash:
    TNT1 A 0 A_PlaySound("weapons/macestruck")
    PUFF AABBCCDD 1 A_FadeOut(0.1)
    stop
  Melee:
    TNT1 A 0 A_PlaySound("weapons/macestruck")
    stop
   }
}

ACTOR GrabberShot : LoreShot
{
    Speed 100
    Damage 1
    Height 4
    Radius 2
    SeeSound None
    DeathSound None
    States
    {
    Spawn:
       TNT1 A 15
       Stop
    }
}
