actor PileDriverWepC : BaseMM8BDMWep
{
Weapon.AmmoUse 7
Weapon.AmmoGive 28
Weapon.SlotNumber 4
Inventory.Pickupmessage "$PU_PILEDRIVER"
Obituary "$OB_PILEDRIVER"
Tag "$TAG_PILEDRIVER"
weapon.ammotype "PileDriverAmmo"
inventory.icon "PLDRICON"
States
{
SpawnLoop:
11WP G 1
loop
Ready:
PDRV A 0 ACS_ExecuteAlways(998,0,DYE_PILEDRIVER)
PDRV A 1 A_WeaponReady
Goto Ready+1
Deselect:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
PDRV A 1 A_Lower
Loop
Select:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
PDRV A 1 A_Raise
Loop
Fire:
PDRV A 0 A_JumpIfNoAmmo("NoAmmo")
PDRV H 0 A_JumpIfInventory("PileDriverAmmo",7,"Windup")
Goto Ready+1
Windup:
SAKH A 0 A_PlaySoundEx("weapon/piledriver","Weapon")
PDRV A 0 A_Stop
PDRV A 0 ACS_NamedExecuteAlways("core_flyplayer",0,0,1)
PDRV A 0 SetPlayerProperty(0,1,PROP_FROZEN)
PDRV A 0 A_Recoil(3)
PDRV A 1 A_TakeInventory("PileDriverAmmo",7)
PDRV A 0 ACS_NamedExecuteAlways("core_flyplayer",0,0,0)
PDRV A 0 SetPlayerProperty(0,0,PROP_FROZEN)
PDRV A 0 A_Stop
PDRV B 1
PDRV B 0 A_Stop
PDRV B 1
PDRV B 0 A_Stop
PDRV C 1 
PDRV C 0 A_Stop
PDRV CC 1 A_Stop
Goto Dash
Dash:
PDRV C 0 ACS_NamedExecuteAlways("core_flyplayer",0,0,1)
PDRV A 0 SetPlayerProperty(0,1,PROP_FROZEN)
Goto Continue
Continue:
PDRV C 0 A_GiveInventory("PileDashPickup")
PDRV C 0 A_SpawnItemEX("PileWave",45,0,28)
PDRV C 0 A_SpawnItemEX("DashDust",0,0,8,0,0,-1)
PDRV C 0 A_JumpIfInventory("PileDriverRecoil",1,"Impact")
PDRV C 1 A_SpawnItemEX("PileDriverCheck",18,0,8,1)

PDRV C 0 A_GiveInventory("DashTimer",1)
PDRV C 0 A_JumpIfInventory("DashTimer",10,"DashStop")
PDRV C 0 A_JumpIfInventory("PileDriverRecoil",1,"Impact")
loop
Impact:
PDRV A 0 ACS_NamedExecuteAlways("core_flyplayer",0,0,0)
PDRV A 0 ACS_NamedExecuteAlways("core_freezeplayer",0,0,0)
PDRV B 0 A_Stop
PDRV B 0 A_SpawnItemEX("ImpactExplosion",20,0,8)
PDRV B 0 A_PlaySoundEx("weapon/piledriven","Weapon")
//PDRV CBB 2
PDRV A 0 ACS_NamedExecuteAlways("core_flyplayer",0,0,0)
PDRV A 0 SetPlayerProperty(0,0,PROP_FROZEN)
PDRV A 0 SetPlayerProperty(0,0,PROP_FLY)
PDRV BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 0 A_Quake(2,20,0,300,0)
PDRV B 0 ThrustThingZ(0,35,0,0)
PDRV B 0 ThrustThing(angle*256/360+128,15,1,0)
PDRV B 0 //ACS_ExecuteAlways(247, 0, -7, 256)
PDRV BB 1
PDRV CCCCC 3
PDRV CC 1
PDRV BBA 3
PDRV A 0 A_TakeInventory("ImpactFlag",999)
PDRV A 0 A_TakeInventory("DashTimer",999)
PDRV A 0 ACS_NamedExecuteAlways("core_flyplayer",0,0,0)
goto Ready+1
DashStop:
PDRV A 0 ACS_NamedExecuteAlways("core_flyplayer",0,0,0)
PDRV A 0 SetPlayerProperty(0,0,PROP_FROZEN)
PDRV A 0 SetPlayerProperty(0,0,PROP_FLY)
PDRV C 0 A_SpawnItemEX("PileWave",45,0,28)
PDRV C 0 A_SpawnItemEX("PileDriverCheck",18,0,8,1)
PDRV C 0 A_SpawnItemEX("DashDust",0,0,8,0,0,-1)
PDRV C 0 A_TakeInventory("DashTimer",999)
PDRV C 0 A_SpawnItemEX("PileWave",45,0,28)
PDRV C 0 A_SpawnItemEX("PileDriverCheck",18,0,8,1)
PDRV C 1 A_SpawnItemEX("DashDust",0,0,8,0,0,-1)
PDRV C 0 A_SpawnItemEX("PileWave",45,0,28)
PDRV C 0 A_SpawnItemEX("PileDriverCheck",18,0,8,1)
PDRV C 1 A_SpawnItemEX("DashDust",0,0,8,0,0,-1)
PDRV C 0 A_SpawnItemEX("PileWave",45,0,28)
PDRV C 0 A_SpawnItemEX("PileDriverCheck",18,0,8,1)
PDRV C 1 A_SpawnItemEX("DashDust",0,0,8,0,0,-1)
PDRV C 0 A_SpawnItemEX("PileWave",45,0,28)
PDRV C 0 A_SpawnItemEX("PileDriverCheck",18,0,8,1)
PDRV C 1 A_SpawnItemEX("DashDust",0,0,8,0,0,-1)
PDRV A 0 ACS_NamedExecuteAlways("core_flyplayer",0,0,0)
PDRV BBBB 1 A_JumpIfInventory("PileDriverRecoil",1,"Impact")
PDRV AAAAAAAAAAAA 1 A_JumpIfInventory("PileDriverRecoil",1,"Impact")
Goto Ready+1
NoAmmo:
PDRV A 1 ACS_Execute(979,0)
Goto Ready+1
ReadyC:
Goto Ready+1
}
}

actor PileDriverCheck : FastProjectile
{
    PROJECTILE
    Obituary "$OB_PILEDRIVER"
    Damagetype "PileDriver"
    height 28
    radius 28
    speed 32
    Damage (30)
    States
    {
    Spawn:
        TNT1 A 0
        TNT1 A 1
        stop
    Death:
		TNT1 A 0 A_Explode (30, 100, 0,0,100)
        TNT1 A 0 A_GiveToTarget("PileDriverRecoil", 1)
        stop
    }
}

actor PileDriverRecoil : Powerup
{
    powerup.duration 10
}


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

actor ImpactFlag : Inventory
{
inventory.amount 1
inventory.maxamount 1
}

actor DashTimer : Inventory
{
inventory.amount 1
inventory.maxamount 20
}

actor PileDashPickup : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIf(z-floorz==0,"Ground")
goto Air
Air:
TNT1 A 0 A_Recoil(-8)
stop
TNT1 A 0 A_Recoil(-8)
stop
Ground:
TNT1 A 0 A_Recoil(-8)
stop
TNT1 A 0 A_Recoil(-8)
stop
}
}

actor PileDriverProtect : PowerProtection
{
Powerup.Duration 8
DamageFactor "PileDriver", 0.0
}

actor DashDust
{
PROJECTILE 
damage (0)
Radius 1
Height 1
scale 2.5
+CLIENTSIDEONLY
+THRUACTORS
+FLOORHUGGER
States
{
Spawn:
TNT1 AA 0 
PLDS AABBCCDD 1 A_FadeOut(.05)
wait
}
}

actor PileWave
{
Translation "192:192=229:229", "198:198=220:220", "202:202=215:215"
PROJECTILE
Damagetype "PileDriver"
Obituary "$OB_PILEDRIVER"
damage (0)
Radius 7
Height 15
scale 2.5
States
{
Spawn:
TNT1 A 0 //A_Explode(3, 10, 0)
IMPD A 1 A_Warp(AAPTR_TARGET, 45, 0, 28, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
stop
}
}

actor ImpactCheck
{
PROJECTILE
Damagetype "PileDriver"
Obituary "$OB_PILEDRIVER"
Damage (3)
radius 20
height 20
scale 2.5
States
{
Spawn:
TNT1 A 0 A_Explode (3, 10, 0)
TNT1 A 1
stop
XDeath:
TNT1 A 0 A_GiveToTarget("ImpactFlag",1)
TNT1 A 1 A_SpawnItemEx("ImpactAOE")
TNT1 AAAAA 5 
stop
Death:
TNT1 A 0 A_GiveToTarget("ImpactFlag",1)
stop
}
}

actor ImpactAOE
{
PROJECTILE
Damagetype "PileDriver"
Obituary "$OB_PILEDRIVER"
Damage (30)
radius 25
height 25
scale 2.5
States
{
Spawn:
TNT1 A 1 //A_Explode (40, 100, 0,0,100)
NAPA EFGHIJKLMNOPQRS 1
stop
}
}

actor ImpactExplosion
{
PROJECTILE
+NOINTERACTION
scale 2.5
States
{
Spawn:
NAPA E 0 A_PlaySoundEx("weapon/pileimpact","Weapon")
NAPA EFGHIJKLMNOPQRS 1
stop
}
}