Actor SubliminationSword : DoomWeapon
{
  Scale 0.7
  Weapon.AmmoType1 "DustMana"
  Weapon.AmmoType2 "DustMana"
  Weapon.AmmoUse1 20
  Weapon.UpSound "SubSword/Pickup"
  Inventory.PickupSound "SubSword/Pickup"
  Inventory.PickupMessage "You got the Sublimination Sword!"
  Weapon.PreferredSkin "Fist-Marine"
  Obituary "%o was amazed that %k actually got this obituary to appear."
  Tag "Sublimination Sword"
  +FLOATBOB
  +WEAPON.AMMO_OPTIONAL
  +WEAPON.NOALERT
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	SBSW A 1 A_WeaponReady
	Loop
  Deselect:
	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
	TNT1 A 0 A_Lower
	SBSW A 1 A_Lower
	Goto Deselect+1
  Select: 
	TNT1 A 0 A_Raise
	SBSW A 1 A_Raise
	Loop
  Fire:
	TNT1 A 0 A_JumpIfInventory("SubSwordModeToken1",1,"Fire2")
	TNT1 A 0 A_JumpIfInventory("SubSwordModeToken2",1,"Fire3")
	SBSW BC 2
  Refire:
	TNT1 A 0 A_PlaySound("Mainyu/Sword",1)
	TNT1 A 0 A_Quake(4,10,0,10,0)
	SBSW DEFGHI 1
	TNT1 A 0 A_CustomPunch((random(150,250)*random(1,4)),1,0,"SubSwordWallHit",128)
	SBSW JKLMN 1
	TNT1 A 5
	TNT1 A 0 A_Refire("Refire")
	Goto Done
  Fire2:
	TNT1 A 0 A_JumpIfInventory("DustMana",30,"Fire2Continue")
	Goto Ready
  Fire2Continue:
	SBSW BC 2
  Refire2:
	TNT1 A 0 A_PlaySound("Mainyu/Sword",1)
	TNT1 A 0 A_Quake(4,20,0,10,0)
	SBS2 AABBCCDDEEFF 1
	TNT1 A 0 A_TakeInventory("DustMana",30,TIF_NOTAKEINFINITE)
	TNT1 A 0 A_FireCustomMissile("PlayerMainyuSwordProjectile",0,0,0,0)
	TNT1 A 0 A_AlertMonsters
	SBS2 GGHHIIJJKK 1
	TNT1 A 5
	TNT1 A 0 A_JumpIfInventory("DustMana",30,2)
	TNT1 A 0 A_Jump(256,2)
	TNT1 A 0 A_Refire("Refire2")
	TNT1 A 0
	Goto Done
  Fire3:
	TNT1 A 0 A_JumpIfInventory("DustMana",50,"Fire3Continue")
	Goto Ready
  Fire3Continue:
	SBSW BC 2
  Refire3:
	TNT1 A 0 A_PlaySound("Mainyu/Sword",1)
	TNT1 A 0 A_Quake(4,20,0,10,0)
	TNT1 A 0 A_TakeInventory("DustMana",50,TIF_NOTAKEINFINITE)
	SBS3 AABBCCDD 1
	TNT1 A 0 A_AlertMonsters
	SBS3 E 1 A_FireCustomMissile("PlayerMainyuRedDarkMatter",-7,0,0,0)
	SBS3 E 1 A_FireCustomMissile("PlayerMainyuRedDarkMatter",-5,0,0,0)
	SBS3 F 1 A_FireCustomMissile("PlayerMainyuRedDarkMatter",-3,0,0,0)
	SBS3 F 1 A_FireCustomMissile("PlayerMainyuRedDarkMatter",-1,0,0,0)
	SBS3 G 1 A_FireCustomMissile("PlayerMainyuRedDarkMatter",1,0,0,0)
	SBS3 G 1 A_FireCustomMissile("PlayerMainyuRedDarkMatter",3,0,0,0)
	SBS3 H 1 A_FireCustomMissile("PlayerMainyuRedDarkMatter",5,0,0,0)
	SBS3 H 1 A_FireCustomMissile("PlayerMainyuRedDarkMatter",7,0,0,0)
	SBS3 IIJJKK 1
	TNT1 A 5
	TNT1 A 0 A_JumpIfInventory("DustMana",50,2)
	TNT1 A 0 A_Jump(256,2)
	TNT1 A 0 A_Refire("Refire3")
	TNT1 A 0
	Goto Done
  AltFire:	
	TNT1 A 0 A_JumpIfInventory("SubSwordModeToken1",1,"AltFire2")
	TNT1 A 0 A_JumpIfInventory("SubSwordModeToken2",1,"AltFire3")
	TNT1 A 0 A_GiveInventory("SubSwordModeToken1")
	SBSW A 1 A_Print("White Matter",1.5)
	TNT1 A 0 A_Refire("NoAutoAltFirePls")
	Goto Ready
  AltFire2:	
	TNT1 A 0 A_TakeInventory("SubSwordModeToken1")
	TNT1 A 0 A_GiveInventory("SubSwordModeToken2")
	SBSW A 1 A_Print("Red Matter",1.5)
	TNT1 A 0 A_Refire("NoAutoAltFirePls")
	Goto Ready
  AltFire3:	
	TNT1 A 0 A_TakeInventory("SubSwordModeToken1")
	TNT1 A 0 A_TakeInventory("SubSwordModeToken2")
	SBSW A 1 A_Print("Life Leech",1.5)
	TNT1 A 0 A_Refire("NoAutoAltFirePls")
	Goto Ready
  Done:
	SBSW OPQR 2
	Goto Ready	
  NoAutoAltFirePls:
	SBSW A 1
	SBSW A 1 A_Refire("NoAutoAltFirePls")
	Goto Ready
  GrenadeCheck:
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	Goto Ready
  GrenadeToss:
	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	SBSW ABC 2
	TNT1 A 3
	HGRN ABC 1
	HGRN D 2
	HGRN EFG 1
	HGRN HI 2
	TNT1 A 15 A_PlayWeaponSound("weapons/hgrenadepin")
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	TNT1 A 0 A_TakeInventory("HandGrenadeAmmo",1)
	HGNE A 1 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
	HGRN J 1
	HGRN KLM 2
	HGRN NO 1
	TNT1 A 6
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,2)
	TNT1 A 0 A_TakeInventory("Hand Grenade",1)
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	TNT1 A 0
	SBSW CBA 2
	Goto Ready
  MineCheck:
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,"MineToss")
	TNT1 A 0 A_TakeInventory("MineAction",1)
	Goto Ready
  MineToss:
	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	SBSW ABC 2
	TNT1 A 8
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	MINE ABCDEF 1		
	TNT1 A 0 A_TakeInventory("MineAmmo",1)	  
	MINE G 1 A_FireCustomMissile("ThrownMine",0,0,0,0)
	MINE HI 1
	MINE JK 2
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,2)
	TNT1 A 0 A_TakeInventory("Land Mine",1)
	TNT1 A 0 A_TakeInventory("MineAction",1)
	TNT1 A 0
	TNT1 A 5
	SBSW CBA 2
	Goto Ready
  Spawn:
	WVBL A 1
	Loop
  }
}

Actor SubSwordModeToken1 : Inventory { }
Actor SubSwordModeToken2 : Inventory { }

Actor SubSwordWallHit : BulletPuff
{
+NOGRAVITY
+PUFFGETSOWNER
+PUFFONACTORS
+EXTREMEDEATH
+FOILINVUL
DamageType "Melee"
AttackSound "SubSword/WallHit"
SeeSound "Mainyu/Meleehit"
RenderStyle Add
Alpha 0.8
Scale 0.8
States
{
Spawn:
Melee:
    TNT1 A 0
	TNT1 A 0 A_SpawnItemEx("RedParticleSpawner",0,0,0,0,0,0,0,128)
	TNT1 A 0 A_Jump(128,"Alt")
	EX97 ABCDEFGHIJ 1 Bright A_FadeOut(0.08)
	Stop
Alt:
	EX98 ABCDEFGHIJ 1 Bright A_FadeOut(0.08)
	Stop	
XDeath:
	TNT1 F 0 
	FAXE F 3 A_GiveToTarget("SubliminationHealth",random(20,40))
	FAXE GHIJK 3
	Stop
    }
}

Actor SubliminationHealth : NewMaxHealthBonus
{
Inventory.MaxAmount 1200
Inventory.Amount 1
}

Actor PlayerMainyuSwordProjectile : MainyuSwordProjectile
{
Species "Player"
+DONTHARMSPECIES
+FOILINVUL
+MTHRUSPECIES
Damagetype "Normal"
States
{
  Death:
	TNT1 A 0 A_SpawnItemEx("BossDeathExplode",0,0,32)
    TNT1 AAAAAAAAAAA 0 A_SpawnItemEx ("2huBossDeathFlame", 0, 0, 0, random(-3,3), random(-3,3), random(-3,3), random (0, 360))
	TNT1 AAAAAAAAAAA 0 A_CustomMissile("2huBossDeathFlame3", random(5, 55), 0, random(0,360), CMF_OFFSETPITCH, frandom(-40, 70))
	TNT1 A 0 A_Explode(500,400,0,0,300)
	TNT1 A 25 Radius_Quake(5,25,0,20,0)
	Stop
	}
}

Actor PlayerMainyuRedDarkMatter : MainyuRedDarkMatter
{  
  Damagetype "Normal"
  Species "Player"
  +DONTHARMSPECIES
  +FOILINVUL
  +MTHRUSPECIES
  States
  {
  Death:
	TNT1 A 0
	TNT1 A 0 A_Playsound("PainLord/Explode1",7)
	TNT1 AAAA 0 A_SpawnItemEx("Debris",0,0,Random(20,40),Random(4,-4),Random(4,-4),Random(4,8),0,128)
	TNT1 AAA 0 A_CustomMissile("MainyuRedDarkmatterKaboom", 0, 0, random(0,360), 2, random(0,360))	
	TNT1 AAA 0 A_CustomMissile("SmokeFX2", 0, 0, random(0,360), 2, random(0,360))
	TNT1 A 0 A_SpawnItemEx("MainyuRedDarkMatterVaporSpawner",0,0,0,0,0,0,0,32)
	TNT1 A 0 A_SpawnItemEx("RedShadowVaporSpawner",0,0,0,0,0,0,0,32)
	TNT1 A 0 A_Explode(130,200,0)
	TNT1 A 15 Radius_Quake(5,15,0,20,0)
	Stop
	}
}