actor HammerThrowWep_NormalBar : NormalBar { args 217, 3 }

actor HammerThrowWep : BaseMM8BDMWep //31258
{
//$Category MM8BDM-Weapons
//$Title Hammer Throw
//$Sprite M3HMZ0
Weapon.AmmoUse 1
Weapon.AmmoGive 28
Weapon.SlotNumber 3
Inventory.Pickupmessage "$PU_HAMMERTHROW"
Obituary "$OB_HAMMERTHROW"
Tag "$TAG_HAMMERTHROW"
weapon.ammotype "HammerThrowAmmo"
inventory.icon "HMTHSI"
States
{
SpawnLoop:
M3HM Z -1
loop
Ready:
M3HM E 0 ACS_NamedExecuteWithResult("core_weaponcolor",CLR_HAMMERTHROW)
M3HM E 0 A_JumpIfNoAmmo("ReadyNoAmmo")
M3HM E 1 A_WeaponReady
Goto Ready+2
ReadyNoAmmo:
M3HM N 1 A_WeaponReady
M3HM N 0 A_JumpIfNoAmmo("ReadyNoAmmo")
Goto Ready+1
Deselect:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
M3HM E 1 A_Lower
Loop
Select:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
M3HM E 1 A_Raise
Loop
AltFire: // Always MidThrow with Alt-Fire.
M3HM F 0 A_JumpIfNoAmmo("NoAmmo")
M3HM F 0 A_PlaySoundEx("weapon/hammerthrow","Weapon")
M3HM F 0 A_JumpIf((pitch<345&&pitch>=270) ||(pitch<90&&pitch>=15), "LoMidThrow")
M3HM F 0 A_Jump(256, "MidThrow")
Fire:
M3HM F 0 A_JumpIfNoAmmo("NoAmmo")
M3HM F 0 A_PlaySoundEx("weapon/hammerthrow","Weapon")
M3HM F 0 A_JumpIf(pitch<345&&pitch>=270, "HiThrow")
M3HM F 0 A_JumpIf(pitch<20&&pitch>=15, "LoMidThrow")
//M3HM F 0 A_JumpIf(pitch<90&&pitch>=20, "LoThrow")
MidThrow:
M3HM F 0 A_FireCustomMissile("MarioHammer",0,1,8,0)
Anim:
M3HM FG 2
M3HM HI 3 
M3HM E 0 A_JumpIfNoAmmo("RefireNoAmmo") // Will Raise Hand without Hammer when ammo is out.
Refire1:
M3HM J 1 A_Refire
Refire2:
M3HM J 1 A_Refire
Refire3:
M3HM K 1 A_Refire
Goto Ready+1
HiThrow:
M3HM F 0 A_FireCustomMissile("MarioHammerHi",0,1,8,0)
M3HM FG 2
M3HM HI 3 
TNT1 A 2
M3HM E 0 A_JumpIfNoAmmo("RefireNoAmmo") // Will Raise Hand without Hammer when ammo is out.
Goto Refire1
LoMidThrow:
M3HM F 0 A_FireCustomMissile("MarioHammerMid",0,1,8,0)
Goto Anim
//LoThrow:
//M3HM F 0 A_FireCustomMissile("MarioHammerLo",0,1,8,0)
//Goto Anim
RefireNoAmmo: 
M3HM E 0 A_JumpIfInventory("HammerThrowAmmo",2, "Refire1") // This will place Hammer back in the hand 
M3HM L 1
M3HM E 0 A_JumpIfInventory("HammerThrowAmmo",2, "Refire2") // on each corresponding frame 
M3HM L 1
M3HM E 0 A_JumpIfInventory("HammerThrowAmmo",2, "Refire3") // if ammo is regained during animation.
M3HM M 1
Goto ReadyNoAmmo
NoAmmo:
M3HM N 1 ACS_NamedExecuteAlways("core_noammo",0)
Goto ReadyNoAmmo
}
}

actor HammerThrowAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 28
+INVENTORY.IGNORESKILL
}

actor MarioHammer : BasicProjectile
{
var int user_TranslateBlackColors;
var int user_thrust;
var int user_bouncefactor;
var int user_hammerframe;
var int user_hammerdamage;
var int user_hammervel;
var int user_ceilingstuck;
//var int user_layhammer;
damagetype "MarioHammer" // [Russ] damagetype was "None", set to "MarioHammer" to distinguish it for copynerf
Obituary "$OB_HAMMERTHROW"
scale 2.5
-NOGRAVITY
+HEXENBOUNCE
+USEBOUNCESTATE
+CANBOUNCEWATER
-ALLOWBOUNCEONACTORS
bouncefactor 0.4
Speed 18
accuracy 48
stamina -20
mass 0
Radius 6
Height 8
gravity 1.6
Damage (CallACS("burst_cbm_damage",20+user_hammerdamage))
reactiontime 5 // [Russ] Desync Fix

States
{
Spawn:
M3HM A 0
M3HM A 0 A_SetUserVar(user_hammervel, stamina)
M3HM A 0 A_Recoil(mass)
M3HM A 0 ThrustThingZ(0, accuracy, 0, 1)
UpdateVars:
M3HM # 0 A_SetUserVar(user_hammerdamage, 0)
M3HM # 0 A_JumpIf(velz>user_hammervel,2)
M3HM # 0 A_SetUserVar(user_hammerdamage, 40)
M3HM # 0 A_JumpIf(user_bouncefactor < 1||velz<-8, 2)
M3HM # 0 A_SetUserVar(user_hammerdamage, -5)
M3HM # 0 A_JumpIf(user_hammerframe == 1 ,"SLoop1")
M3HM # 0 A_JumpIf(user_hammerframe == 2 ,"SLoop2")
M3HM # 0 A_JumpIf(user_hammerframe == 3 ,"SLoop3")
SLoop0:
M3HM A 3 A_SetUserVar(user_hammerframe, 1)
Goto UpdateVars
SLoop1:
M3HM B 3 A_SetUserVar(user_hammerframe, 2)
Goto UpdateVars
SLoop2:
M3HM C 3 A_SetUserVar(user_hammerframe, 3)
Goto UpdateVars
SLoop3:
M3HM D 3 A_SetUserVar(user_hammerframe, 0)
Goto UpdateVars
Bounce.Floor:
M3HM # 0 A_SetUserVar(user_ceilingstuck, 0)
M3HM # 0 A_SetUserVar(user_bouncefactor, user_bouncefactor+1)
M3HM # 0 A_SetUserVar(user_hammervel, -24)
M3HM # 0 A_JumpIf(velz < 8, /*4*/ 3)
//M3HM # 0 A_SetUserVar(user_layhammer, 0)
M3HM # 0 A_SetUserVar(user_bouncefactor, 0)
M3HM # 0 ThrustThingZ(0, velz*6, 0, 0)
M3HM # 0 A_CountDown // [Russ] Desync Fix
Goto UpdateVars
Bounce.Ceiling:
M3HM # 0 A_SetUserVar(user_hammervel, -8)
M3HM # 0 A_SetUserVar(user_ceilingstuck, user_ceilingstuck+1) 	//Failsafe if the hammer gets stuck in the ceiling.
M3HM # 0 A_JumpIf(user_ceilingstuck == 4, "Death") 				//Why do projectiles still get stuck in the ceiling?
Goto UpdateVars
XDeath: // [Russ] Desync Fix
TNT1 A 0 A_SpawnItemEx("ExplosionEffect1",0,0,10,0,0,0,0,SXF_NOCHECKPOSITION)
stop
Death: // [Russ] Desync Fix
M3HM # 0 A_SetUserVar(user_hammerdamage, -10)
M3HM # 0 A_Stop
M3HM # 0 A_ChangeFlag("BOUNCEONFLOORS", false)
M3HM # 0 A_Jump(128,5)
M3HM # 1 A_SetAngle(angle+45)
M3HM # 1 A_SetAngle(angle+45)
M3HM # 3 A_SetAngle(angle+45)
M3HM # 0 A_Jump(256,"FallOver")
M3HM # 1 A_SetAngle(angle-45)
M3HM # 1 A_SetAngle(angle-45)
M3HM # 3 A_SetAngle(angle-45)
FallOver:
//M3HM # 0 A_JumpIf(user_layhammer == 1, "LayHammer")
TNT1 A 0 A_SpawnItemEx("HammerDeathS",0,0,00,0,0,0,0,SXF_NOCHECKPOSITION)
stop
//LayHammer:
//TNT1 A 0 A_SpawnItemEx("HammerDeathL",0,0,10,0,0,0,0,SXF_NOCHECKPOSITION)
//stop
}}

actor MarioHammerHi : MarioHammer
{
speed 4
accuracy 96
stamina -16
mass -2
}

actor MarioHammerMid : MarioHammer
{
speed 20
accuracy 0
stamina -24
mass -4
States
{
Spawn:
M3HM A 0
M3HM A 0 A_SetUserVar(user_bouncefactor, 3)
goto Super::Spawn
}}

/*
actor MarioHammerLo : MarioHammer
{
speed 4
accuracy 32
stamina -24
mass -3
States
{
Spawn:
M3HM A 0
M3HM A 0 A_SetUserVar(user_bouncefactor, 5)
M3HM # 0 A_SetUserVar(user_layhammer, 1)

goto Super::Spawn
}}
*/

actor HammerDeathS : BasicProjectile
{
var int user_TranslateBlackColors;
PROJECTILE
damagetype "MarioHammer" // [Russ] damagetype was "None", set to "MarioHammer" to distinguish it for copynerf
Obituary "$OB_HAMMERTHROW2"
scale 2.5
+NOEXPLODEFLOOR
-NOGRAVITY
Speed 0
Radius 8
Height 4
gravity 1.6
Damage (CallACS("burst_cbm_damage",5))
reactiontime 17
States
{
Spawn:
M3HM O 0
M3HM O 0 A_Jump(128,"Spawn2")
M3HM P 0
Spawn2:
"####" # 1 A_Countdown
loop
Death:
TNT1 A 0 A_SpawnItemEx("ExplosionEffect1",0,0,10,0,0,0,0,SXF_NOCHECKPOSITION)
stop
}}

/*
actor HammerDeathL : HammerDeathS
{
reactiontime 105
}
*/