//Mobility recoded
actor TenguBladeWep_NormalBar : NormalBar { args 208, 93 }
actor TenguBladeWep_ScriptBar : ScriptBar {}

actor TenguBladeWep : BaseMM8BDMWep 10012
{
//$Category MM8BDM-Weapons/Close
//$Title Tengu Blade
//$Sprite TBLAX0
Weapon.AmmoUse 2
Weapon.AmmoGive 28
Weapon.SlotNumber 4
Inventory.Pickupmessage "$PU_TENGUBLADE"
Obituary "$OB_TENGUBLADE"
Tag "$TAG_TENGUBLADE"
weapon.ammotype "TenguBladeAmmo"
inventory.icon "TENBLI"
States
{
SpawnLoop:
TBLA X -1
loop

Ready:
TNT1 A 0 A_GiveInventory("TenguBladeColorHandler",1)
TNT1 A 0 A_JumpIfInventory("IsMegaMan",1,"ReadyMega")
TNT1 A 0 A_JumpIfInventory("IsProtoMan",1,"ReadyProto")
TNT1 A 0 A_JumpIfInventory("IsBass",1,"ReadyBass")
TNT1 A 0 A_JumpIfInventory("IsDuo",1,"ReadyDuo")
TNT1 A 1
Goto Ready+1

ReadyMega:
K7ME A 0 A_JumpIfInventory("UltAttackFlag",1,"UltimateAttackCheck")
K7ME A 1 A_WeaponReady
Goto ReadyMega
ReadyProto:
K7PR A 0 A_JumpIfInventory("UltAttackFlag",1,"UltimateAttackCheck")
K7PR A 1 A_WeaponReady
Goto ReadyProto
ReadyBass:
K7BA A 0 A_JumpIfInventory("UltAttackFlag",1,"UltimateAttackCheck")
K7BA A 1 A_WeaponReady
Goto ReadyBass
ReadyDuo:
K7DU A 0 A_JumpIfInventory("UltAttackFlag",1,"UltimateAttackCheck")
K7DU A 1 A_WeaponReady
Goto ReadyDuo

Deselect:
"####" A 0
Goto DeselectSwap
Select:
"####" A 0
Goto SelectSwap

Fire:
Hold:
"####" A 0 A_JumpIfNoAmmo("NoAmmo")
"####" A 0 A_JumpIfInventory("PowerGearPowerup",1,"GearCheck")
Fire.Resume:
"####" A 0 A_JumpIfInventory("TenguBladeCharge", 25, "Charge2")
"####" A 0 A_JumpIfInventory("TenguBladeCharge", 15, "Charge")
"####" A 1 A_GiveInventory("TenguBladeCharge", 1)
"####" A 0 A_Refire
Goto Fire1

Charge:
"####" B 0 A_JumpIfInventory("TenguBladeCharge", 25, "Charge2")
"####" B 1 A_GiveInventory("TenguBladeCharge", 1)
"####" B 0 A_Refire
Goto Fire1

Charge2:
"####" C 1 A_JumpIfInventory("IsBot", 1, "BotCharge")
"####" C 0 A_Refire
"####" C 0 A_JumpIf(CallACS("core_CheckFooting"),"DashStart")
Goto Fire1

BotCharge:
"####" C 1 A_Jump(64, "Fire1")
"####" C 0 A_Jump(32, 2)
"####" C 0 A_Refire
Goto Charge2+2

DashStart:
"####" C 1 ACS_NamedExecuteAlways("core_unsolidplayer",0,0,USP_TOGGLEON)
"####" A 0 A_GiveInventory("CutterFlag", 10)
"####" A 0 A_GiveInventory("TakeTenguBladeAmmo",1) //sync >_>
"####" A 0 A_TakeInventory("TenguBladeCharge", 999)
"####" A 0 A_Recoil(CallACS("VC_XYMob",-50))
"####" A 0 A_PlaySoundEx("weapons/mmb/tengubladedash","Weapon")
"####" A 0 ACS_NamedExecuteAlways("core_freezeplayer",0,0,1)
Goto DashAttack

DashAttack:
"####" A 0 A_Recoil(CallACS("VC_XYMob",-1))
"####" E 0 ACS_NamedExecute("VC_SetState",0,41)
"####" D 1 A_SpawnItemEx("TenguDash", 48, 0, 32, momx, momy, momz, 0, SXF_ABSOLUTEMOMENTUM) //A_FireCustomMissile("TenguDash",0,0,11,-8)
"####" A 0 A_TakeInventory("CutterFlag", 1)
"####" A 0 A_JumpIfInventory("CutterFlag", 1, "DashAttack")
DashFinish:
"####" A 0 ACS_NamedExecuteAlways("core_freezeplayer",0,0,0)
"####" A 0 ACS_NamedExecuteAlways("core_unsolidplayer",0,0,USP_TOGGLEOFF_DAMAGE,ACS_NamedExecuteWithResult("core_getmaxhealth")/10)
"####" A 0 A_ScaleVelocity(0.25)
"####" EFG 2
"####" Z 8 A_TakeInventory("TenguBladeCharge", 999)
"####" CBA 2
"####" A 0 A_Refire
Goto Ready+1

Fire1:
"####" A 0 A_JumpIfNoAmmo("NoAmmo")
"####" A 0 ACS_NamedExecute("VC_SetState",0,39)
"####" A 0 A_PlaySoundEx("weapons/mmb/tengubladefire","Weapon")
"####" A 0 A_TakeInventory("TenguBladeCharge", 999)
"####" B 1 A_GiveInventory("FireTenguSlash1", 1) // SpreadRune
"####" C 1
"####" D 2 
"####" E 2 A_GiveInventory("FireTenguSlash2", 1) // SpreadRune
"####" F 2
"####" G 2 A_GiveInventory("TenguBladeClassPickUp",1)
"####" Z 8 A_TakeInventory("TenguBladeCharge", 999)
"####" CBA 2
"####" A 1 A_Refire
Goto Ready+1

GearCheck:
"####" A 0 A_JumpIfInventory("TenguBladeAmmo",9,"Fire.Gear")
Goto Fire.Resume

Fire.Gear:
"####" A 0 ACS_NamedExecute("VC_SetState",0,39)
"####" A 0 A_TakeInventory("TenguBladeAmmo",9)
"####" A 0 A_PlaySoundEx("weapon/chargekick","Body")
"####" A 0 A_PlaySoundEx("weapons/mmb/tengubladefire","Weapon")
"####" BCDEF 1
"####" G 2 A_FireCustomMissile("KamaitachiCopyWep",0,0,8,0)
"####" Z 12
"####" CBA 2
Goto Ready+1

NoAmmo:
"####" A 0 ACS_NamedExecute("VC_SetState",0,40)
"####" A 1 ACS_NamedExecuteAlways("core_noammo",0)
Goto Ready+1
}
}

actor TenguBladeColorHandler : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("IsBass",1,"Pickup2")
TNT1 A 0 ACS_NamedExecuteWithResult("core_weaponcolor",CLR_TENGUBLADE)
stop

Pickup2:
TNT1 A 0 ACS_ExecuteAlways(998,0,20103)
stop
}
}

actor TenguBladeCharge : Inventory
{
inventory.amount 1
inventory.maxamount 25
}

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

actor FireTenguSlash1 : CustomInventory
{
    States
    {
    Pickup:
		TNT1 A 0 A_JumpIfInventory("IsBass",1,"Pickup2")
        TNT1 A 0 A_SpawnItemEx ("TenguSlash1",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,0,SXF_ABSOLUTEMOMENTUM,0)
        TNT1 A 0 A_JumpIfInventory("PowerSpreadRune", 1, "PickupSpread")
        stop
    PickupSpread:
        TNT1 A 0 A_SpawnItemEx ("TenguSlash1",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,20,SXF_ABSOLUTEMOMENTUM,0)
        TNT1 A 0 A_SpawnItemEx ("TenguSlash1",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,-20,SXF_ABSOLUTEMOMENTUM,0)
        stop
	Pickup2:
		TNT1 A 0 A_SpawnItemEx ("TenguSlash1B",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,0,SXF_ABSOLUTEMOMENTUM,0)
        TNT1 A 0 A_JumpIfInventory("PowerSpreadRune", 1, "PickupSpread2")
        stop
	PickupSpread2:
        TNT1 A 0 A_SpawnItemEx ("TenguSlash1B",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,20,SXF_ABSOLUTEMOMENTUM,0)
        TNT1 A 0 A_SpawnItemEx ("TenguSlash1B",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,-20,SXF_ABSOLUTEMOMENTUM,0)
        stop
    }
}

actor FireTenguSlash2 : CustomInventory
{
    States
    {
    Pickup:
		TNT1 A 0 A_JumpIfInventory("IsBass",1,"Pickup2")
        TNT1 A 0 A_SpawnItemEx ("TenguSlash2",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,0,SXF_ABSOLUTEMOMENTUM,0)
        TNT1 A 0 A_JumpIfInventory("PowerSpreadRune", 1, "PickupSpread")
        stop
    PickupSpread:
        TNT1 A 0 A_SpawnItemEx ("TenguSlash2",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,20,SXF_ABSOLUTEMOMENTUM,0)
        TNT1 A 0 A_SpawnItemEx ("TenguSlash2",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,-20,SXF_ABSOLUTEMOMENTUM,0)
        stop
	Pickup2:
		TNT1 A 0 A_SpawnItemEx ("TenguSlash2B",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,0,SXF_ABSOLUTEMOMENTUM,0)
        TNT1 A 0 A_JumpIfInventory("PowerSpreadRune", 1, "PickupSpread2")
        stop
	PickupSpread2:
        TNT1 A 0 A_SpawnItemEx ("TenguSlash2B",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,20,SXF_ABSOLUTEMOMENTUM,0)
        TNT1 A 0 A_SpawnItemEx ("TenguSlash2B",cos(-pitch)*56,8,32+(sin(-pitch)*48), momx, momy, 0,-20,SXF_ABSOLUTEMOMENTUM,0)
        stop
    }
}

actor TenguDash : BasicExplosion
{
damagetype "TenguSlash"
Obituary "$OB_TENGUBLADE"
States
{
Spawn:
TNT1 A 0
SCLA HI 1 A_Explode(6,64,0)
SCLA J 0 A_Explode(6,64,0)
SCLA J 1 A_ScaleVelocity(0.5)
SCLA J 1 A_FadeOut(0.5)
stop
Death:
TNT1 A 0
stop
}
}

actor TenguSlash1 : BasicExplosion
{
damagetype "TenguSlash"
Obituary "$OB_TENGUBLADE"
States
{
Spawn:
TBLA E 0
TBLA E 0 A_SpawnItemEx("PropBlowerEffect")
TBLA EF 2 A_Explode(7,80,0)
stop
}
}
actor TenguSlash1B : TenguSlash1 {translation "4:4=168:168", "93:93=95:95"}

actor TenguSlash2 : TenguSlash1
{
States
{
Spawn:
TBLA G 0
TBLA G 0 A_SpawnItemEx("PropBlowerEffect")
TBLA GF 2 A_Explode(7,80,0)
stop
}
}
actor TenguSlash2B : TenguSlash2 {translation "4:4=168:168", "93:93=95:95"}

actor TenguBladeClassPickUp : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("IsBass",1,"Pickup2")
TNT1 A 0 A_FireCustomMissile("TenguBlade",0,1,8,0 + CallACS("VC_DuoCheck"))
stop

Pickup2:
TNT1 A 0 A_FireCustomMissile("TenguBladeB",0,1,8,0)
stop
}
}

actor TenguBlade : BasicProjectile
{
Radius 12
Height 8
damage (24)
Bouncetype Classic
+BOUNCEONWALLS
+CANBOUNCEWATER
WALLBOUNCEFACTOR 0.91
BOUNCEFACTOR 0.91
BOUNCECOUNT 6
damagetype "TenguBlade"
Obituary "$OB_TENGUBLADE"
speed 30
States
{
Spawn:
TNT1 A 3
TBLA HI 2
TBLA BCD 3 
Goto Spawn+3
Death:
TNT1 A 0 
stop
}
}
actor TenguBladeB : TenguBlade {translation "4:4=168:168", "93:93=95:95"}

actor TakeTenguBladeAmmo : CustomInventory
{
states
{
Pickup:
TNT1 A 0 A_TakeInventory("TenguBladeAmmo", 2, TIF_NOTAKEINFINITE)
stop
}
}

//Edited CBM
actor KamaitachiCopyWep
{
PROJECTILE
damagetype "TenguBlade"
Obituary "%o was severed by %k's Kamaitachi."
+THRUACTORS
+BOUNCEONWALLS
+BOUNCEONCEILINGS
+NOEXPLODEFLOOR
+DONTSPLASH
BounceFactor 0.75
WallBounceFactor 0.95
BounceCount 7
damage (0)
Radius 7
Height 7
Speed 40
scale 2.5
states
{
Spawn:
TNT1 AA 0 A_GiveInventory("ProjectileCode",1)
TGUH K 0
TGUH K 0 A_JumpIf( momx*momx + momy*momy < 324 && momz == 0, "Death")
TE8P G 1 A_PlaySoundEx("weapon/tengushot","Weapon")
goto Spawn2
Spawn2:
TE8P GGGHHHIIIJJJKKK 1 A_GiveInventory("KamaitachiCopyWep_P",1)
loop
Death:
TNT1 A 0
stop
}
}

actor KamaitachiCopyWep_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_Explode(sqrt(momx*momx + momy*momy)/10+4,48,0,0,24)
TNT1 A 0 ThrustThingZ(0,3-(momz >= 0),0,1)
stop
}
}
