ACTOR Mainyu : GenericBoss //not technically a 2hu but who cares
{
FloatSpeed 8
Speed 8
Health 20000
Mass 0x7FFFFFFF
DamageFactor "PlayerNemesisPlasma", 0.0
DamageFactor "Legendary", 0.0
DamageFactor "Melee", 0.05
DamageFactor "Crush", 0.1
DamageFactor "Acid", 0.05
DamageFactor "Ice", 0.0
DamageFactor "Fire", 0.0
DamageFactor "Poison", 0.0
DamageFactor "PoisonCloud", 0.0
DamageFactor "Electric", 0.001
DamageFactor "Disintegrate", 0.001
DamageFactor "DrainLife", 0.0
DamageFactor "Extreme", 0.0
DamageFactor "Player", 0.1
DamageFactor "Players", 0.02
DamageFactor "PyroShot", 0.0
DamageFactor "PlayerPyro", 0.0
DamageFactor "PDTPuff", 0.0
DamageFactor "Explosion", 0.1
DamageFactor "NuclearFire", 0.01
DamageFactor "BFG9500Ball", 0.25
DamageFactor "BFGSplash", 0.25
DamageFactor "UpBFG9500Ball", 0.25
DamageFactor "UpBFGSplash", 0.15
DamageFactor "PDTBFG", 0.03
DamageFactor "PDTBFGTracer", 0.03
DamageFactor "PlayerDevBall", 0.02
DamageFactor "PlayerDevBall2", 0.02
DamageFactor "PlayerDevTracer", 0.02
DamageFactor "PlayerBHole", 0.05
DamageFactor "LegendaryPlayer", 0.015
DamageFactor "PlayerHellfire", 0.1
DamageFactor "SuperWeapon", 0.0
DamageFactor "LegendaryGuruPlayer", 0.015
DamageFactor 0.5
DamageFactor "SatanGuard", 0.0
DamageFactor "Moloch", 0.0
DamageFactor "ZombieDev", 0.0
DamageFactor "Terminator", 0.0
DamageFactor "Legendary1", 0.0
DamageFactor "LegendaryGuru", 0.0
DamageFactor "UltimateLegendary", 0.0
DamageFactor "Cybers", 0.0
DamageFactor "Hell", 0.0
DamageFactor "Commander", 0.0
DamageFactor "Baby15K", 0.0
DamageFactor "Cyber10K", 0.0
DamageFactor "DemolisherEx", 0.0
DamageFactor "DarkDemoEx", 0.0
DamageFactor "CerChainguns", 0.0
DamageFactor "CerEnergyBall", 0.0
DamageFactor "HellComet", 0.0
DamageFactor "HFCyber", 0.0
DamageFactor "DBFG2", 0.1
DamageFactor "DBFG10K2", 0.1
DamageFactor "DBFGSplash2", 0.1
DamageFactor "PlayerDBFG2", 0.1
DamageFactor "PlayerDBFG10K2", 0.1
DamageFactor "PlayerDBFGSplash2", 0.1
DamageFactor "TrueLegendaryDamage", 0.4
DamageFactor "TrueLegendaryPlayer", 0.4
Species "Mainyu"
ActiveSound "Mainyu/Active"
//DeathSound "Mainyu/Death"
SeeSound "Mainyu/Sight"
PainSound "Mainyu/Pain"
//AttackSound "MReimu/TeleportIn"
Painchance 10
Painchance "Melee", 256
PainChance "PlayerDBFG2", 256
PainChance "PlayerDBFG210K", 256
PainChance "PlayerDBFG10K2", 256
PainChance "DBFG210K", 256
PainChance "DBFG2Splash", 256
PainChance "DBFG2", 256
PainChance "DBFG", 256
PainChance "PlayerDBFG", 256
PainChance "DBFG10K2", 256
MeleeThreshold 200
MeleeRange 120
Obituary "%o was erased from existance by Mainyu."
HitObituary "%o's organs were torn through a dimensional rift by Mainyu."
Tag "\c[d8]Spenta Mainyu\c-"
+BOSSDEATH
+NORADIUSDMG
+NOTIMEFREEZE
+MISSILEMORE
+MISSILEEVENMORE
+NOTELEFRAG
+QUICKTORETALIATE
+DONTRIP
+NOFEAR
+CANTSEEK
+ALWAYSFAST
+SEEINVISIBLE
+NOICEDEATH
var int user_music;
var int user_missile;
var int user_teleloop;
var int user_mode;
var int user_script;
var int user_rage;
var int user_currenthp;
var int user_effects;
var int user_CheckPower;
var int user_LastStand;
States
{
  Spawn:
	TNT1 A 0 NoDelay A_JumpIf(ACS_NamedExecuteWithResult("Disable2hu") == 1, "Remove")
  SpawnLoop:
	TNT1 A 0 A_SetInvulnerable
	TNT1 A 0 A_Gravity
	TNT1 A 0 A_ChangeFlag("NODAMAGE",1)
	TNT1 A 0 A_ChangeFlag("FLOAT",0)
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
    MAIS A 1 A_LookEx(LOF_FULLVOLSEESOUND,0,0,0,360,"See2")
	Loop
  Remove:
	TNT1 A 1
	TNT1 A 0 A_SpawnItemEx("Cyberdemon",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
	TNT1 A 0 A_ChangeFlag("COUNTKILL", FALSE)
	TNT1 A 0
	Stop
  See2:
	TNT1 A 0 A_JumpIf(user_music == 1,3)
    TNT1 A 0 ACS_NamedExecuteAlways("StartMonsterMusic",0,734)
	TNT1 A 0 A_SetUserVar("user_music",1)
	TNT1 A 0 A_JumpIf(user_script == 1,3)
    TNT1 A 0 ACS_NamedExecuteAlways("MainyuHardScript")
	TNT1 A 0 A_SetUserVar("user_script",1)
	TNT1 A 0 A_SpawnItemEx("MainyuBarrier",0,0,50)
    MAIS BC 10
    MAIS D 44
    TNT1 A 0 ACS_NamedExecuteAlways("MainyuSky",0)
	TNT1 A 0 A_SpawnItem("MainyuLightning")
    MAIS EFGH 6
    MAIS IJKLMNOPQ 4
    TNT1 A 0 A_SpawnItemEx("MainyuSparkleSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("HardMainyu") == 1,2)
	TNT1 A 0 A_ChangeFlag("ALWAYSFAST",0)
	TNT1 A 0 A_UnSetInvulnerable
	TNT1 A 0 A_NoGravity
	TNT1 A 0 A_ChangeFlag("NODAMAGE",0)
	TNT1 A 0 A_ChangeFlag("FLOAT",1)
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
    Goto See
  Idle:
	TNT1 A 0 A_JumpIf(user_mode == 1,"Idle.Black")
	TNT1 A 0 A_Look
    MAIN ABCD 2 A_Wander
	TNT1 A 0 A_Look
    MAIN EFGH 2 A_Wander
	TNT1 A 0 A_Look
    MAIN IJKL 2 A_Wander
	TNT1 A 0 A_Look
    MAIN MNOP 2 A_Wander
	TNT1 A 0 A_Look
    MAIN QRST 2 A_Wander
	TNT1 A 0 A_Look
    MAIN UVWX 2 A_Wander
	TNT1 A 0 A_Look
    MAIN "YZ[]" 2 A_Wander
	Loop
  Idle.Black:
	TNT1 A 0 A_Look
    2MAN ABCD 2 A_Wander
	TNT1 A 0 A_Look
    2MAN EFGH 2 A_Wander
	TNT1 A 0 A_Look
    2MAN IJKL 2 A_Wander
	TNT1 A 0 A_Look
    2MAN MNOP 2 A_Wander
	TNT1 A 0 A_Look
    2MAN QRST 2 A_Wander
	TNT1 A 0 A_Look
    2MAN UVWX 2 A_Wander
	TNT1 A 0 A_Look
    2MAN "YZ[]" 2 A_Wander
	Loop
  ChangeMode:
	TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("HardMainyu") == 1, "ChangeModeHard")
	TNT1 A 0 A_SetUserVar("user_currenthp",ACS_NamedExecuteWithResult("Hem_GetCurrentHealth"))
	TNT1 A 0 A_JumpIf(user_mode == 1,"ChangeMode2")
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
    MAIT AB 5
	TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2",0,0,50)
	TNT1 A 0 A_SpawnItemEx("MainyuWingsWhite1")
    TNT1 A 0 A_PlaySound("Mainyu/Transform")
	TNT1 A 0 A_SetUserVar("user_mode",1)
	MAIT CD 5
	MAIT I 20
	TNT1 A 0 A_RemoveChildren(1)
    TNT1 A 0 A_SpawnItemEx("MainyuFireSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 ACS_NamedExecuteAlways("MainyuTag",0,1)
	TNT1 A 0 A_SpawnItemEx("MainyuWingsBlack2")
	MAIT I 20
    MAIT HG 5
	TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2Black",0,0,50)
    TNT1 A 0 A_PlaySound("Mainyu/Transform")
	MAIT FE 5
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_JumpIf((user_currenthp - ACS_NamedExecuteWithResult("Hem_GetCurrentHealth")) > 500,"ChaseTeleport")
	Goto See
  ChangeMode2:
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
    MAIT EF 5
	TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2Black",0,0,50)
	TNT1 A 0 A_SpawnItemEx("MainyuWingsBlack1")
    TNT1 A 0 A_PlaySound("Mainyu/Transform")
	TNT1 A 0 A_SetUserVar("user_mode",0)
	MAIT GH 5
	MAIT I 20
	TNT1 A 0 A_RemoveChildren(1)
    TNT1 A 0 A_SpawnItemEx("MainyuSparkleSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 ACS_NamedExecuteAlways("MainyuTag",0,2)
	TNT1 A 0 A_SpawnItemEx("MainyuWingsWhite2")
	MAIT I 20
    MAIT DC 5
	TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2",0,0,50)
    TNT1 A 0 A_PlaySound("Mainyu/Transform")
	MAIT BA 5
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_JumpIf((user_currenthp - ACS_NamedExecuteWithResult("Hem_GetCurrentHealth")) > 500,"ChaseTeleport.Black")
	Goto See
  ChangeModeHard:
	TNT1 A 0 A_JumpIf(user_mode == 1,"ChangeModeHard2")
	TNT1 A 0 A_RemoveChildren(1)
    TNT1 A 0 A_SpawnItemEx("MainyuFireSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 ACS_NamedExecuteAlways("MainyuTag",0,1)
	TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2Black",0,0,50)
    TNT1 A 0 A_PlaySound("Mainyu/Transform")
	TNT1 A 0 A_SetUserVar("user_mode",1)
	Goto See
  ChangeModeHard2:
	TNT1 A 0 A_RemoveChildren(1)
    TNT1 A 0 A_SpawnItemEx("MainyuSparkleSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 ACS_NamedExecuteAlways("MainyuTag",0,2)
	TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2",0,0,50)
    TNT1 A 0 A_PlaySound("Mainyu/Transform")
	TNT1 A 0 A_SetUserVar("user_mode",0)
	Goto See
  See:
	TNT1 A 0 A_JumpIf(user_music == 1,3)
    TNT1 A 0 ACS_NamedExecuteAlways("StartMonsterMusic",0,734)
	TNT1 A 0 A_SetUserVar("user_music",1)
	TNT1 A 0 A_JumpIf(user_script == 1,3)
    TNT1 A 0 ACS_NamedExecuteAlways("MainyuHardScript")
	TNT1 A 0 A_SetUserVar("user_script",1)
	TNT1 A 0 A_UnSetInvulnerable
	TNT1 A 0 A_ChangeFlag("NODAMAGE",0)
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_ChangeFlag("FRIGHTENED",0)
	TNT1 A 0 A_FadeIn(1.0)
	TNT1 A 0 A_NoGravity
	TNT1 A 0 A_ChangeFlag("FLOAT",1)
	TNT1 A 0 A_Stop
	TNT1 A 0 A_JumpIf(user_CheckPower == 1,2)
	TNT1 A 0 A_Jump(256,"CheckPower") //she also adapts her resistance depending on how many runes you have.
	TNT1 A 0 A_JumpIf(user_LastStand == 1,2)
	TNT1 A 0 A_JumpIfHealthLower(3500, "LastStand")
	TNT1 A 0 A_JumpIf(user_rage == 1,"SeeRage")
	TNT1 A 0 A_JumpIfHealthLower(7000,"StartRage")
	TNT1 A 0 A_JumpIf(user_mode == 1,"See.Black")
	TNT1 A 0 A_Jump(30,"Teleport","ChaseTeleport")
    MAIN ABCDEFGHIJKLMN 2 A_Chase
	TNT1 A 0 A_Jump(30,"Teleport","ChaseTeleport")
	MAIN "OPQRSTUVWXYZ[]" 2 A_Chase
    Loop
  See.Black:
	TNT1 A 0 A_Jump(30,"Teleport.Black","ChaseTeleport.Black")
    2MAN ABCDEFGHIJKLMN 2 A_Chase
	TNT1 A 0 A_Jump(30,"Teleport.Black","ChaseTeleport.Black")
	2MAN "OPQRSTUVWXYZ[]" 2 A_Chase
    Loop
  SeeRage:
	TNT1 A 0 A_JumpIf(user_mode == 1,"SeeRage.Black")
	TNT1 A 0 A_Jump(30,"Teleport","ChaseTeleport")
    MAIN ABCDEFGHIJKLMN 2 A_Chase//("Melee","MissileRage",CHF_FASTCHASE)
	TNT1 A 0 A_Jump(30,"Teleport","ChaseTeleport")
	MAIN "OPQRSTUVWXYZ[]" 2 A_Chase//("Melee","MissileRage",CHF_FASTCHASE)
    Loop
  SeeRage.Black:
	TNT1 A 0 A_Jump(30,"Teleport.Black","ChaseTeleport.Black")
    2MAN ABCDEFGHIJKLMN 2 A_Chase//("Melee","MissileRage",CHF_FASTCHASE)
	TNT1 A 0 A_Jump(30,"Teleport.Black","ChaseTeleport.Black")
	2MAN "OPQRSTUVWXYZ[]" 2 A_Chase//("Melee","MissileRage",CHF_FASTCHASE)
    Loop
  StartRage:
	TNT1 A 0 A_SetInvulnerable
	TNT1 A 0 A_ChangeFlag("NODAMAGE",1)
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
	TNT1 A 0 A_ChangeFlag("NOCLIP",1)
	TNT1 A 0 A_JumpIf(user_mode == 1,"StartRage.Black")
	TNT1 A 0 A_SpawnItemEx("MainyuWingsWhiteAttack",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_SpawnItemEx("MainyuWhiteAttackCopy",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 45 A_SetTranslucent(0.0)
	TNT1 A 0 A_RemoveChildren(1)
	TNT1 A 0 A_PlaySound("Mainyu/Ding")
	TNT1 A 20 A_UnSetShootable
	TNT1 A 0 A_PlaySound("Mainyu/Rage",2,1.0,0,ATTN_NONE)
	TNT1 A 0 A_SetUserVar("user_rage",1)
	TNT1 A 0 A_ChangeFlag("ALWAYSFAST",1)
	TNT1 A 0 ACS_NamedExecuteAlways("MainyuRage",0)
	TNT1 A 0 A_SetUserVar("user_teleloop",0)
	TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("HardMainyu") == 1, "StartRageLoop")
	TNT1 A 245
	Goto StartRageEnd
  StartRageLoop:
	TNT1 A 0 A_ChangeFlag("NOCLIP",1)
	TNT1 A 0 A_JumpIf(user_teleloop >= 245,"StartRageEnd")	 
	TNT1 A 0 A_SetUserVar("user_teleloop",user_teleloop+1)
	TNT1 AAA 0 A_Chase("","",CHF_NOPLAYACTIVE)
	TNT1 A 1 A_Chase("","",CHF_NOPLAYACTIVE)
	Goto StartRageLoop+1
  StartRageEnd:
	TNT1 A 0 A_JumpIf(user_mode == 1,"StartRageEnd.Black")
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	MAI7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuSparkleSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_UnSetInvulnerable
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_ChangeFlag("NODAMAGE",0)
	TNT1 A 0 A_ChangeFlag("NOCLIP",0)
	MAI7 J 1 A_SetShootable
	Goto See
  StartRage.Black:
	TNT1 A 0 A_SpawnItemEx("MainyuWingsBlackAttack",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_SpawnItemEx("MainyuBlackAttackCopy",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 45 A_SetTranslucent(0.0)
	TNT1 A 0 A_RemoveChildren(1)
	TNT1 A 0 A_PlaySound("Mainyu/Ding")
	TNT1 A 0 A_UnSetShootable
	TNT1 A 0 A_PlaySound("Mainyu/Rage",2,1.0,0,ATTN_NONE)
	TNT1 A 0 A_SetUserVar("user_rage",1)
	TNT1 A 0 A_ChangeFlag("ALWAYSFAST",1)
	TNT1 A 0 ACS_NamedExecuteAlways("MainyuRage",0)
	TNT1 A 0 A_SetUserVar("user_teleloop",0)
	TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("HardMainyu") == 1, "StartRageLoop")
	TNT1 A 245
	Goto StartRageEnd
  StartRageEnd.Black:
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	2MA7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuFireSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_UnSetInvulnerable
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_ChangeFlag("NODAMAGE",0)
	TNT1 A 0 A_ChangeFlag("NOCLIP",0)
	2MA7 J 1 A_SetShootable
	Goto See
   CheckPower:
	   TNT1 A 0 A_SetUserVar("user_CheckPower",1)
       TNT1 A 0 A_JumpIfInTargetInventory("NexusStrength",1,"CheckPower2")
       Goto See
   CheckPower2:
       TNT1 A 0 A_JumpIfInTargetInventory("TerminatorDamage2",1,"FinalTruePower")
       Goto TruePower
   TruePower:
       TNT1 A 0 A_GiveInventory("GodFinalBattleResistanceGiver3",1)
	   TNT1 A 0 A_GiveInventory("Health",10000)
       Goto See
   FinalTruePower:
       TNT1 A 0 A_GiveInventory("GodFinalBattleResistanceGiver6",1)
	   TNT1 A 0 A_GiveInventory("Health",20000)
       Goto See
   LastStand:
       TNT1 A 0 A_SetUserVar("user_LastStand",1)
       TNT1 A 0 A_JumpIfInTargetInventory("TerminatorDamage2",1,"TrueLastStand")
       TNT1 A 0 A_GiveInventory("GodsFinalBattleShield3",1)
	   TNT1 A 0 A_GiveInventory("GodsFullImunityGiver3",1)
	   TNT1 A 0 A_GiveInventory("Health",500)
       Goto See
   TrueLastStand:
       TNT1 A 0 A_JumpIfInTargetInventory("NexusSpread",1,"FinalTrueLastStand")
       TNT1 A 0 A_GiveInventory("GodsFinalBattleShield5",1)
	   TNT1 A 0 A_GiveInventory("GodsFullImunityGiver5",1)
	   TNT1 A 0 A_GiveInventory("Health",2000)
       Goto See
   FinalTrueLastStand:
       TNT1 A 0 A_GiveInventory("GodsFinalBattleShield5",1)
	   TNT1 A 0 A_GiveInventory("GodsFullImunityGiver5",1)
	   TNT1 A 0 A_GiveInventory("Health",5000)
       Goto See
  Teleport:
	TNT1 A 0 A_RemoveChildren(1)
	MAI7 J 1 A_UnSetShootable
	TNT1 A 0 A_PlaySound("MReimu/TeleportOut",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	MAI7 JKKKLLLMMM 1 A_FadeOut(0.1,0)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_Wander
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_Wander
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	MAI7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuSparkleSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	MAI7 J 1 A_SetShootable
	Goto See
  Teleport.Black:
	TNT1 A 0 A_RemoveChildren(1)
	2MA7 J 1 A_UnSetShootable
	TNT1 A 0 A_PlaySound("MReimu/TeleportOut",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	2MA7 JKKKLLLMMM 1 A_FadeOut(0.1,0)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_Wander
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_Wander
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	2MA7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuFireSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	2MA7 J 1 A_SetShootable
	Goto See
  ChaseTeleportAfraid:
	TNT1 A 0 A_ChangeFlag("FRIGHTENED",1)
  ChaseTeleport:
	TNT1 A 0 A_RemoveChildren(1)
	MAI7 A 1 A_UnSetShootable
	TNT1 A 0 A_PlaySound("MReimu/TeleportOut",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	MAI7 JKKKLLLMMM 1 A_FadeOut(0.1,0)
	TNT1 A 0 A_SetUserVar("user_teleloop",random(0,100))
	TNT1 A 0 A_JumpIf(user_rage == 1,2)
	TNT1 A 0 A_Jump(256,2)
	TNT1 A 0 A_ChangeFlag("NOCLIP",1)
  ChaseTeleportLoop:
	TNT1 A 0 A_JumpIf(user_teleloop >= 300,"ChaseTeleportEnd")	 
	TNT1 A 0 A_SetUserVar("user_teleloop",user_teleloop+1)
	TNT1 A 0 A_Jump(254,2)
	TNT1 A 0 A_Playsound("Mainyu/Laugh",2)
	TNT1 AAA 0 A_Chase("ChaseTeleportEnd","",CHF_NOPLAYACTIVE)
	TNT1 A 1 A_Chase("ChaseTeleportEnd","",CHF_NOPLAYACTIVE)
	Loop
  ChaseTeleportEnd:
	TNT1 A 0 A_ChangeFlag("FRIGHTENED",0)
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	MAI7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuSparkleSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_ChangeFlag("NOCLIP",0)
	MAI7 J 1 A_SetShootable
	Goto See
  ChaseTeleportAfraid.Black:
	TNT1 A 0 A_ChangeFlag("FRIGHTENED",1)
  ChaseTeleport.Black:
	TNT1 A 0 A_RemoveChildren(1)
	2MA7 A 1 A_UnSetShootable
	TNT1 A 0 A_PlaySound("MReimu/TeleportOut",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	2MA7 JKKKLLLMMM 1 A_FadeOut(0.1,0)
	TNT1 A 0 A_SetUserVar("user_teleloop",random(0,100))
	TNT1 A 0 A_JumpIf(user_rage == 1,2)
	TNT1 A 0 A_Jump(256,2)
	TNT1 A 0 A_ChangeFlag("NOCLIP",1)
  ChaseTeleportLoop.Black:
	TNT1 A 0 A_JumpIf(user_teleloop >= 300,"ChaseTeleportEnd.Black")	 
	TNT1 A 0 A_SetUserVar("user_teleloop",user_teleloop+1)
	TNT1 A 0 A_Jump(252,2)
	TNT1 A 0 A_Playsound("Mainyu/Laugh")
	TNT1 A 1 A_Chase("ChaseTeleportEnd.Black","",CHF_NOPLAYACTIVE)
	Loop
  ChaseTeleportEnd.Black:
	TNT1 A 0 A_ChangeFlag("FRIGHTENED",0)
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	2MA7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuFireSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_ChangeFlag("NOCLIP",0)
	2MA7 A 1 A_SetShootable
	Goto See
  Pain:
	TNT1 A 0 A_JumpIf(user_mode == 1,"Pain.Black")
	TNT1 A 0 A_Jump(30,"Teleport","ChaseTeleportAfraid")
	TNT1 A 0 A_Pain
	TNT1 A 0 A_Jump(256,"PainFrame1","PainFrame2")
    Goto See
  PainFrame1:
	MAI2 W 8
    Goto See
  PainFrame2:
	MAI2 "X" 8
    Goto See
  Pain.Black:
	TNT1 A 0 A_Jump(30,"Teleport.Black","ChaseTeleportAfraid.Black")
	TNT1 A 0 A_Pain
	TNT1 A 0 A_Jump(256,"PainFrame1.Black","PainFrame2.Black")
    Goto See
  PainFrame1.Black:
	2MA2 W 8
    Goto See
  PainFrame2.Black:
	2MA2 "X" 8
    Goto See
  Pain.Melee:
	TNT1 A 0 A_JumpIf(user_mode == 1,"PainMelee.Black")
	TNT1 A 0 A_Jump(192,"SuperMelee")
	Goto Missile
  PainMelee.Black:
	TNT1 A 0 A_Jump(192,"SuperMelee.Black")
	Goto Missile
  Pain.PlayerDBFG10K2:
  Pain.DBFG10K2:
  Pain.DBFG:
  Pain.PlayerDBFG:
  Pain.DBFG2:
  Pain.PlayerDBFG210K:
  Pain.DBFG210K:
  Pain.DBFG2Splash:
  Pain.PlayerDBFG2:
	TNT1 A 0 A_PlaySound("Mainyu/Sword",1)
	TNT1 A 0 A_CustomMissile("MainyuSwordProjectile",32)
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
	TNT1 A 0 A_JumpIfCloser(350,"ChargeMelee")
	TNT1 A 0 A_Jump(128,"TryMassElectricSpawn","TryVoidTravel")
	TNT1 A 0 A_JumpIfCloser(850,"TryShockwave")
	TNT1 A 0 A_Jump(256,"TryMassElectricSpawn","TryVoidTravel")
	Goto See
  TryMassElectricSpawn:
	TNT1 A 0 A_JumpIf(user_mode == 1,"MassElectricSpawn")
	TNT1 A 0 A_RemoveChildren(1)
    TNT1 A 0 A_SpawnItemEx("MainyuFireSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 ACS_NamedExecuteAlways("MainyuTag",0,1)
	TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2Black",0,0,50)
    TNT1 A 0 A_PlaySound("Mainyu/Transform")
	TNT1 A 0 A_SetUserVar("user_mode",1)
	Goto MassElectricSpawn
  TryShockwave:
	TNT1 A 0 A_JumpIf(user_mode == 0,"ShockwaveContinue")
	TNT1 A 0 A_RemoveChildren(1)
    TNT1 A 0 A_SpawnItemEx("MainyuSparkleSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 ACS_NamedExecuteAlways("MainyuTag",0,2)
	TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2",0,0,50)
    TNT1 A 0 A_PlaySound("Mainyu/Transform")
	TNT1 A 0 A_SetUserVar("user_mode",0)
	Goto ShockwaveContinue
  TryVoidTravel:
	TNT1 A 0 A_JumpIf(user_mode == 1,"VoidTravel.Black")
	Goto VoidTravel
  ChargeMelee:
	TNT1 A 0 A_PlaySound("Mainyu/Melee",7)
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 ThrustThingZ(0,20,1,1)
	TNT1 A 0 A_Recoil(-80)
  Melee:
	TNT1 A 0 A_JumpIf(user_mode == 1,"Melee.Black")
	TNT1 A 0 A_JumpIfInTargetInventory("IsPlayer",1,2)
	TNT1 A 0 A_Jump(64,"SuperMelee")
    MAI3 AB 2 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	MAI3 CD 2 Fast
	TNT1 A 0 A_CustomBulletAttack(0,0,1,0,"MainyuLeech",120)
	MAI3 E 3 Fast A_CustomMeleeAttack(random(150,300),"Mainyu/Meleehit","none","Mainyu")
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	MAI3 FG 2 Fast
	TNT1 A 0 A_JumpIfCloser(300,"ContinueMelee")
	MAI3 HIJKL 2
	Goto See
  ContinueMelee:
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 ThrustThingZ(0,5,1,1)
	TNT1 A 0 A_Recoil(-40)
	MAI3 OP 2 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 ThrustThingZ(0,5,1,1)
	TNT1 A 0 A_Recoil(-40)
	MAI3 QR 2 Fast
	TNT1 A 0 A_CustomBulletAttack(0,0,1,0,"MainyuLeech",120)
	MAI3 S 3 A_CustomMeleeAttack(random(150,300),"Mainyu/Meleehit","none","Mainyu")
	MAI3 TU 2 Fast
	TNT1 A 0 A_JumpIfCloser(300,"ContinueMelee2")
	MAI3 VWXYZ 2 Fast
	Goto See
  ContinueMelee2:
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 ThrustThingZ(0,5,1,1)
	TNT1 A 0 A_Recoil(-40)
	MAI4 ABCD 2 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 ThrustThingZ(0,5,1,1)
	TNT1 A 0 A_Recoil(-40)
	MAI4 EF 2 Fast
	TNT1 A 0 A_CustomBulletAttack(0,0,1,0,"MainyuLeech",120)
	MAI4 G 3 A_CustomMeleeAttack(random(150,300),"Mainyu/Meleehit","none","Mainyu")
	MAI4 HIJKLMNOP 2 Fast
	Goto See
  SuperMelee:
	MAI5 MNO 4 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	MAI5 PQ 4 Fast
	TNT1 A 0 A_CustomBulletAttack(0,0,1,0,"SuperMainyuLeech",120)
	MAI5 R 5 A_CustomMeleeAttack(random(4000,6000),"Mainyu/Meleehit","none","Mainyu")
	MAI5 STUVW 3 Fast
	Goto See
  Melee.Black:
	TNT1 A 0 A_JumpIfInTargetInventory("IsPlayer",1,2)
	TNT1 A 0 A_Jump(64,"SuperMelee.Black")
    2MA3 AB 2 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	2MA3 CD 2 Fast
	TNT1 A 0 A_CustomBulletAttack(0,0,1,0,"MainyuLeech",120)
	2MA3 E 3 A_CustomMeleeAttack(random(150,300),"Mainyu/Meleehit","none","Mainyu")
	2MA3 FG 2 Fast
	TNT1 A 0 A_JumpIfCloser(300,"ContinueMelee.Black")
	2MA3 HIJKL 2 Fast
	Goto See
  ContinueMelee.Black:
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 ThrustThingZ(0,5,1,1)
	TNT1 A 0 A_Recoil(-40)
	2MA3 OP 2 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 ThrustThingZ(0,5,1,1)
	TNT1 A 0 A_Recoil(-40)
	2MA3 QR 2 Fast
	TNT1 A 0 A_CustomBulletAttack(0,0,1,0,"MainyuLeech",120)
	2MA3 S 3 Fast A_CustomMeleeAttack(random(150,300),"Mainyu/Meleehit","none","Mainyu")
	2MA3 TU 2 Fast
	TNT1 A 0 A_JumpIfCloser(300,"ContinueMelee2.Black")
	2MA3 VWXYZ 2 Fast
	Goto See
  ContinueMelee2.Black:
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 ThrustThingZ(0,5,1,1)
	TNT1 A 0 A_Recoil(-40)
	2MA4 ABCD 2 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 ThrustThingZ(0,5,1,1)
	TNT1 A 0 A_Recoil(-40)
	2MA4 EF 2 Fast
	TNT1 A 0 A_CustomBulletAttack(0,0,1,0,"MainyuLeech",120)
	2MA4 G 3 Fast A_CustomMeleeAttack(random(150,300),"Mainyu/Meleehit","none","Mainyu")
	2MA4 HIJ 2 Fast
	//TNT1 A 0 A_JumpIfCloser(300,"ContinueMelee3.Black")
	2MA4 KLMNOP 2 Fast
	Goto See
  SuperMelee.Black:
	2MA5 MNO 4 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	2MA5 PQ 4 Fast
	TNT1 A 0 A_CustomBulletAttack(0,0,1,0,"SuperMainyuLeech",120)
	2MA5 R 5 A_CustomMeleeAttack(random(4000,6000),"Mainyu/Meleehit","none","Mainyu")
	2MA5 STUVW 3 Fast
	Goto See
  Missile:
	TNT1 A 0 A_JumpIfCloser(350,"ChargeMelee")
	TNT1 A 0 A_JumpIf(user_mode == 1,"Missile.Black")
	TNT1 A 0 A_Jump(64,"ChangeMode")
	TNT1 A 0 A_Jump(100,"Teleport","ChaseTeleport")
	TNT1 A 0 A_Jump(128,"PortalProjectiles","SpawnElectricity","Shockwave")
	TNT1 A 0 A_Jump(90,"SwordProjectiles")
	TNT1 A 0 A_Jump(40,"LightStorm","VoidTravel")
	Goto NormalAttack
	
  Missile.Black:
	TNT1 A 0 A_Jump(128,"GroundFire","SpawnElectricity.Black")
	TNT1 A 0 A_Jump(100,"Teleport.Black","ChaseTeleport.Black")
	TNT1 A 0 A_Jump(85,"SubliminationSword","MassElectricSpawn","Shock")
	TNT1 A 0 A_Jump(50,"DarkStorm","VoidTravel.Black")
	Goto DarkMatterSwing
  NormalAttack:
	TNT1 A 0 A_PlaySound("Mainyu/Attack1",2)
	MAI2 ABC 4 Fast
	MAI2 DDDDDDDDEEEEEEEEFFFFFFFF 1 A_CustomMissile("MainyuHornRodFX",32,0,frandom(-10,10),CMF_OFFSETPITCH,frandom(-1,1))
	MAI2 GHIJK 4 Fast
	Goto See
  PortalProjectiles:
	TNT1 A 0 A_PlaySound("Mainyu/Attack2",2)
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
	TNT1 A 0 A_SpawnItemEx("MainyuWhitePortal",0,0,100)
	MAI7 JKLM 5 Fast
	TNT1 A 0 A_SetUserVar("user_missile",0)
  PortalProjectilesLoop:
	TNT1 A 0 A_JumpIf(user_missile >= 7,"PortalProjectilesEnd")	 
	TNT1 A 0 A_SetUserVar("user_missile",user_missile+1)
	TNT1 A 0 A_SpawnItemEx("MainyuWhitePortal",0,0,100)
	MAI7 MMMMMMMMMMMMMMMMMMMM 1 A_CustomMissile("MainyuPortalProjectile",100,0,random(-15,15),CMF_OFFSETPITCH,random(-4,4))
	Loop
  PortalProjectilesEnd:
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	MAI7 LKJ 4 Fast
	Goto See
  PortalProjectilesRage:
	TNT1 A 0 A_PlaySound("Mainyu/Attack7",2)
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
	TNT1 A 0 A_SpawnItemEx("MainyuWhitePortal",0,0,100)
	MAI7 JKLM 5 Fast
	TNT1 A 0 A_SetUserVar("user_missile",0)
  PortalProjectilesRageLoop:
	TNT1 A 0 A_JumpIf(user_missile >= 7,"PortalProjectilesEnd")	 
	TNT1 A 0 A_SetUserVar("user_missile",user_missile+1)
	TNT1 A 0 A_SpawnItemEx("MainyuWhitePortal",0,0,100)
	MAI7 MMMMM 4 A_CustomMissile("MainyuPortalProjectileBig",100,0,random(-25,25),CMF_OFFSETPITCH,random(-4,4))
	Loop
  SpawnElectricity:
	TNT1 A 0 A_PlaySound("Mainyu/Electric")
	TNT1 A 0 A_PlaySound("Mainyu/Attack3",2)
	TNT1 A 0 A_SpawnItemEx("MainyuSentientElectric",0,0,100)
	MAI7 JKLMMMM 4 Fast
	MAI7 LKJ 5 Fast
	Goto See
  Shockwave:
	TNT1 A 0 A_JumpIfCloser(850,"ShockwaveContinue")
	Goto PortalProjectiles
  ShockwaveContinue:
	TNT1 A 0 A_PlaySound("Mainyu/Attack4",2)
	MAI2 ABC 6 Fast
	TNT1 A 0 A_PlaySound("Mainyu/FloorshitCharge",7)
	TNT1 A 0 A_SpawnItemEx("MainyuFloorshitCharge",0,0,40)
	MAI2 DEFGHIJKL 3 Fast
	TNT1 A 0 ThrustThingZ(0,25,0,1)
	MAI7 ABC 7 Fast
	TNT1 A 0 A_Stop
	MAI7 DE 7 Fast
	TNT1 A 0 A_CustomMissile("MainyuShockwaveExplodeBig",-100,0,0,CMF_AIMDIRECTION|CMF_TRACKOWNER)
	MAI7 FGHI 6 Fast
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	Goto See
  SwordProjectiles:
	TNT1 A 0 A_PlaySound("Mainyu/Attack10",2)
    MAI3 AB 4 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	MAI3 CD 4 Fast
	MAI3 E 6 A_CustomMissile("MainyuSwordProjectile",32)
	MAI3 FG 4 Fast
	MAI3 OP 4 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	MAI3 QR 4 Fast
	MAI3 S 6 A_CustomMissile("MainyuSwordProjectile",32)
	MAI3 TU 4 Fast
	MAI4 ABCD 4 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	MAI4 EF 4 Fast
	MAI4 G 6 A_CustomMissile("MainyuSwordProjectile",32)
	MAI4 HIJKLMNOP 3 Fast
	Goto See
  LightStorm:
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
	TNT1 A 0 A_PlaySound("Mainyu/Superattack1",2,1.0,0,ATTN_NONE)
	TNT1 A 0 A_SpawnItemEx("MainyuWingsWhiteAttack",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_SpawnItemEx("MainyuWhiteAttackCopy",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 45
	TNT1 A 0 A_SetInvulnerable
	TNT1 A 0 A_ChangeFlag("NODAMAGE",1)
	TNT1 A 0 A_RemoveChildren(1)
	TNT1 A 0 A_PlaySound("Mainyu/Ding")
	//TNT1 A 0 ThrustThingZ(0,40,0,0)
	TNT1 A 0 A_UnSetShootable
	TNT1 A 18
	//TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2",0,0,50)
	TNT1 A 0 A_Stop
	TNT1 A 0 A_JumpIf(user_rage == 1,"LightStormRage")
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 4 A_SpawnItemEx("MainyuCometRain",Random(-3000,3000),Random(-3000,3000),0,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 A 80
	TNT1 AAAAAAA 10 A_VileTarget("MainyuStrikeBeam")
	TNT1 AAAAAAAAAAAAAAAAAAAAAAA 4 A_SpawnItemEx("MainyuCometRain",Random(-3000,3000),Random(-3000,3000),0,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 A 0 A_SpawnItemEx("MainyuBigStrikeBeam",0,0,-1000)
	TNT1 AAAAAAAAAAAAAAAA 4 A_SpawnItemEx("MainyuStrikeBeam",Random(-1500,1500),Random(-1500,1500),-1000,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 A 170
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	MAI7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuSparkleSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_UnSetInvulnerable
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_ChangeFlag("NODAMAGE",0)
	MAI7 J 1 A_SetShootable
	Goto See
  LightStormRage:
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 4 A_SpawnItemEx("MainyuCometRain",Random(-3000,3000),Random(-3000,3000),0,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 A 80
	TNT1 AAAAAAAAAAAAAA 5 A_VileTarget("MainyuStrikeBeam")
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2 A_SpawnItemEx("MainyuCometRain",Random(-3000,3000),Random(-3000,3000),0,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 A 0 A_SpawnItemEx("MainyuBigStrikeBeam",0,0,-1000)
	TNT1 A 0 A_SpawnItemEx("MainyuBigStrikeBeam",Random(-1500,1500),Random(-1500,1500),-1000,0,0,0,0,SXF_NOCHECKPOSITION)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2 A_SpawnItemEx("MainyuStrikeBeam",Random(-1500,1500),Random(-1500,1500),-1000,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 A 170
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	MAI7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuSparkleSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_UnSetInvulnerable
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_ChangeFlag("NODAMAGE",0)
	MAI7 J 1 A_SetShootable
	Goto See
  VoidTravel:
	TNT1 A 0 A_PlaySound("Mainyu/Superattack3",1,1.0,0,ATTN_NONE)
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
	MAIT ABB 20 Fast
	TNT1 A 0 A_PlaySound("MReimu/Cast1")
	TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2",0,0,50)
	MAIT J 60 Fast
	TNT1 A 0 A_UnSetShootable
	TNT1 A 0 A_SetInvulnerable
	TNT1 A 0 A_ChangeFlag("NODAMAGE",1)
	TNT1 A 0 A_SetTranslucent(1.0)
	TNT1 A 0 A_RemoveChildren(1)
	TNT1 A 0 A_PlaySound("Mainyu/Disappear",7)
	TNT1 A 0 A_SpawnItemEx("MainyuVoidTravelEffect",0,0,50)
	TNT1 AAA 1 A_SpawnItemEx("MainyuVoidTravelFake")
	TNT1 A 30
	TNT1 A 0 A_SetUserVar("user_missile",0)
  VoidTravelLoop:
	TNT1 A 0 A_JumpIf(user_missile >= 20,"VoidTravelEnd")	 
	TNT1 A 0 A_SetUserVar("user_missile",user_missile+1)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_Wander
	TNT1 AAAAAAAAAAAA 0 A_Chase("","",CHF_NOPLAYACTIVE)
	TNT1 A 12 Fast A_CustomMissile("MainyuVoidTravelSlash",32)
	Loop
  VoidTravelEnd:
	TNT1 A 0 A_JumpIf(user_mode == 1,"VoidTravelEnd.Black")
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	MAI7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuSparkleSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_UnSetInvulnerable
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_ChangeFlag("NODAMAGE",0)
	MAI7 J 1 A_SetShootable
	Goto See
  SpawnElectricity.Black:
	TNT1 A 0 A_PlaySound("Mainyu/Electric")
	TNT1 A 0 A_PlaySound("Mainyu/Attack3",2)
	TNT1 A 0 A_SpawnItemEx("MainyuSentientElectric",0,0,100)
	2MA7 JKLMMMM 4 Fast
	2MA7 LKJ 5 Fast
	Goto See
  MassElectricSpawn:
	TNT1 A 0 A_PlaySound("Mainyu/Attack6",2)
	2MA7 JKLMN 5 Fast
	TNT1 A 0 A_SetUserVar("user_missile",0)
  MassElectricSpawnLoop:
	TNT1 A 0 A_JumpIf(user_missile >= 8,"MassElectricSpawnEnd")
	TNT1 A 0 A_SetUserVar("user_missile",user_missile+1)
	2MA7 OPOPOP 3 Fast
	TNT1 A 0 A_PlaySound("Mainyu/Electric")
	TNT1 A 0 A_SpawnItemEx("MainyuSentientElectric",random(-700,700),random(-700,700),random(0,200))
	Loop
  MassElectricSpawnEnd:
	2MA7 OPQRST 5 Fast
	Goto See
  GroundFire:
	2MA2 ABC 4 Fast
	TNT1 AAAAAAA 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,random(-20,20))
	2MA2 DEFGHI 2 Fast
	TNT1 AAAAAAA 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,random(-20,20))
	2MA2 DEFGHI 2 Fast
	TNT1 AAAAAAA 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,random(-20,20))
	2MA2 DEFGHI 2 Fast
	TNT1 AAAAAAA 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,random(-20,20))
	2MA2 DEFGHI 2 Fast
	TNT1 AAAAAAA 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,random(-20,20))
	2MA2 DEFGHIJK 2 Fast
	TNT1 A 0 A_Jump(200,"ChangeMode")
	Goto See
  DarkMatterSwing:
	TNT1 A 0 A_PlaySound("Mainyu/Attack5",2)
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	2MA5 MN 5
	2MA5 O 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-32)
	2MA5 O 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-28)
	2MA5 O 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-24)
	2MA5 O 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-20)
	2MA5 O 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-16)
	2MA5 P 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-12)
	2MA5 P 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-8)
	2MA5 P 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-4)
	2MA5 P 1 A_CustomMissile("MainyuRedDarkMatter",32,0,0)
	2MA5 P 1 A_CustomMissile("MainyuRedDarkMatter",32,0,4)
	2MA5 Q 1 A_CustomMissile("MainyuRedDarkMatter",32,0,8)
	2MA5 Q 1 A_CustomMissile("MainyuRedDarkMatter",32,0,12)
	2MA5 Q 1 A_CustomMissile("MainyuRedDarkMatter",32,0,16)
	2MA5 Q 1 A_CustomMissile("MainyuRedDarkMatter",32,0,20)
	2MA5 Q 1 A_CustomMissile("MainyuRedDarkMatter",32,0,24)
	2MA5 R 1 A_CustomMissile("MainyuRedDarkMatter",32,0,28)
	2MA5 R 1 A_CustomMissile("MainyuRedDarkMatter",32,0,32)
	2MA5 RSTUVW 3
	TNT1 A 0 A_Jump(200,"ChangeMode")
	Goto See
  DarkMatterSwing.Rage:
	TNT1 A 0 A_PlaySound("Mainyu/Attack5",2)
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	2MA5 MN 3
	2MA5 O 0 A_CustomMissile("MainyuRedDarkMatter",32,0,-32)
	2MA5 O 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-28)
	2MA5 O 0 A_CustomMissile("MainyuRedDarkMatter",32,0,-24)
	2MA5 O 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-20)
	2MA5 O 0 A_CustomMissile("MainyuRedDarkMatter",32,0,-16)
	2MA5 P 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-12)
	2MA5 P 0 A_CustomMissile("MainyuRedDarkMatter",32,0,-8)
	2MA5 P 1 A_CustomMissile("MainyuRedDarkMatter",32,0,-4)
	2MA5 P 0 A_CustomMissile("MainyuRedDarkMatter",32,0,0)
	2MA5 P 1 A_CustomMissile("MainyuRedDarkMatter",32,0,4)
	2MA5 Q 0 A_CustomMissile("MainyuRedDarkMatter",32,0,8)
	2MA5 Q 1 A_CustomMissile("MainyuRedDarkMatter",32,0,12)
	2MA5 Q 0 A_CustomMissile("MainyuRedDarkMatter",32,0,16)
	2MA5 Q 1 A_CustomMissile("MainyuRedDarkMatter",32,0,20)
	2MA5 Q 0 A_CustomMissile("MainyuRedDarkMatter",32,0,24)
	2MA5 R 1 A_CustomMissile("MainyuRedDarkMatter",32,0,28)
	2MA5 R 0 A_CustomMissile("MainyuRedDarkMatter",32,0,32)
	2MA5 RSTUVW 2
	TNT1 A 0 A_Jump(200,"ChangeMode")
	Goto See
  DarkStorm:
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
	TNT1 A 0 A_PlaySound("Mainyu/Superattack2",2,1.0,0,ATTN_NONE)
	TNT1 A 0 A_SpawnItemEx("MainyuWingsBlackAttack",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_SpawnItemEx("MainyuBlackAttackCopy",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 45
	TNT1 A 0 A_SetInvulnerable
	TNT1 A 0 A_ChangeFlag("NODAMAGE",1)
	TNT1 A 0 A_RemoveChildren(1)
	TNT1 A 0 A_PlaySound("Mainyu/Ding")
	//TNT1 A 0 ThrustThingZ(0,40,0,0)
	TNT1 A 0 A_UnSetShootable
	TNT1 A 18
	//TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2",0,0,50)
	TNT1 A 0 A_Stop
	TNT1 A 0 A_JumpIf(user_rage == 1,"DarkStormRage")
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 4 A_SpawnItemEx("MReimuDarkMatterRain",Random(-3000,3000),Random(-3000,3000),0,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 AAAAAAAAAAAAAAAAAAAAAA 4 A_SpawnItemEx("MReimuDarkMatterRain2",Random(-3000,3000),Random(-3000,3000),0,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 A 0 A_SpawnItemEx("MainyuBigStrikeBeamBlack",0,0,-1000)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAA 4 A_SpawnItemEx("MainyuStrikeBeamBlack",Random(-1500,1500),Random(-1500,1500),-1000,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAA 2 A_RadiusThrust(-1500,2048,RTF_NOIMPACTDAMAGE|RTF_NOTMISSILE)
	TNT1 A 30
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	2MA7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuFireSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_UnSetInvulnerable
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_ChangeFlag("NODAMAGE",0)
	2MA7 J 1 A_SetShootable
	TNT1 A 0 A_Jump(200,"ChangeMode")
	Goto See
  DarkStormRage:
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 4 A_SpawnItemEx("MReimuDarkMatterRain",Random(-3000,3000),Random(-3000,3000),0,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 A 0 A_VileTarget("MainyuBigStrikeBeamBlack")
	TNT1 AAAAAAAAAAAAAAAAAAAAAA 4 A_SpawnItemEx("MReimuDarkMatterRain2",Random(-3000,3000),Random(-3000,3000),0,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 A 0 A_SpawnItemEx("MainyuBigStrikeBeamBlack",0,0,-1000)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2 A_SpawnItemEx("MainyuStrikeBeamBlack",Random(-1500,1500),Random(-1500,1500),-1000,0,0,0,SXF_NOCHECKPOSITION,0)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAA 2 A_RadiusThrust(-1500,2048,RTF_NOIMPACTDAMAGE|RTF_NOTMISSILE)
	TNT1 A 30
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	2MA7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuFireSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_UnSetInvulnerable
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_ChangeFlag("NODAMAGE",0)
	2MA7 J 1 A_SetShootable
	TNT1 A 0 A_Jump(200,"ChangeMode")
	Goto See
  SubliminationSword:
	2MA3 A 3 A_PlaySound("Mainyu/Attack8",2,1.0,0,ATTN_NONE)
	2MA3 BBBBBBB 3 A_SpawnItemEx("TrueNemesisHellionSmokeSpawner")
	TNT1 A 0 A_PlaySound("Mainyu/Sword")
	2MA3 CDEF 5
	TNT1 A 0 A_JumpIfTargetInLOS(2)
	TNT1 A 0 A_Jump(256,2)
	TNT1 A 0 A_GiveToTarget("MainyuSubliminationGiver",1)
	2MA3 GHIJKL 4
	Goto See
  Shock:
	TNT1 A 0 A_PlaySound("Mainyu/Attack9",7)
	TNT1 A 0 A_PlaySound("Mainyu/HitscanWarn",6)
	2MA9 ABCDEEEFGHIJ 4
	TNT1 A 0 A_SetUserVar("user_missile",0)
  ShockLoop:
	TNT1 A 0 A_JumpIf(user_missile >= 8,"ShockEnd")
	TNT1 A 0 A_SetUserVar("user_missile",user_missile+1)
	2MA9 KL 4 A_CustomBulletAttack(2,2,1,random(20,50),"MainyuShockPuff",0,CBAF_NORANDOM)
	Loop
  ShockEnd:
	2MA9 MN 5
	TNT1 A 0 A_Jump(200,"ChangeMode")
	Goto See
  VoidTravel.Black:
	TNT1 A 0 A_PlaySound("Mainyu/Superattack3",1,1.0,0,ATTN_NONE)
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
	MAIT EFF 20 Fast
	TNT1 A 0 A_PlaySound("MReimu/Cast1")
	TNT1 A 0 A_SpawnItemEx("MReimuCastEffect2",0,0,50)
	MAIT J 60 Fast
	TNT1 A 0 A_UnSetShootable
	TNT1 A 0 A_SetInvulnerable
	TNT1 A 0 A_ChangeFlag("NODAMAGE",1)
	TNT1 A 0 A_SetTranslucent(1.0)
	TNT1 A 0 A_RemoveChildren(1)
	TNT1 A 0 A_PlaySound("Mainyu/Disappear",7)
	TNT1 A 0 A_SpawnItemEx("MainyuVoidTravelEffect",0,0,50)
	TNT1 AAA 1 A_SpawnItemEx("MainyuVoidTravelFakeBlack")
	TNT1 A 30
	TNT1 A 0 A_SetUserVar("user_missile",0)
	Goto VoidTravelLoop
  VoidTravelEnd.Black:
	TNT1 A 0 A_PlaySound("MReimu/TeleportIn",7)
	TNT1 A 0 A_SpawnItemEx("MReimuTeleportEffect",0,0,40)
	2MA7 MMMLLLKKKJ 1 A_FadeIn(0.1)
    TNT1 A 0 A_SpawnItemEx("MainyuFireSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
	TNT1 A 0 A_UnSetInvulnerable
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 A_ChangeFlag("NODAMAGE",0)
	2MA7 J 1 A_SetShootable
	Goto See
  Death:
	TNT1 A 0 A_ChangeFlag("NOGRAVITY",1)
	TNT1 A 0 A_SetUserVar("user_missile",0)
	TNT1 A 0 A_JumpIf(user_mode == 1,"Death.Black")
	MAI2 LMN 4
	TNT1 A 0 A_RemoveChildren(1)
	TNT1 A 0 A_PlaySound("Mainyu/DeathSpeech",2,1.0,0,ATTN_NONE)
  DeathLoop:
	TNT1 A 0 A_JumpIf(user_missile >= 85,"ActualDeath")	 
	TNT1 A 0 A_SetUserVar("user_missile",user_missile+1)
	TNT1 A 0 A_SpawnItemEx("MainyuDeathExplosion4",random(0,128),0,random(16,100),frandom(1,8),0,frandom(1,8),random(0,360),0,200)
	MAI2 N 4 A_SpawnItemEx("MainyuDeathExplosion3",0,0,32,frandom(-6,6),frandom(-6,6),frandom(-6,6))
	Loop
  Death.Black:
	2MA2 LMN 4
	TNT1 A 0 A_RemoveChildren(1)
	TNT1 A 0 A_PlaySound("Mainyu/DeathSpeech",2,1.0,0,ATTN_NONE)
  DeathLoop.Black:
	TNT1 A 0 A_JumpIf(user_missile >= 85,"ActualDeath")	 
	TNT1 A 0 A_SetUserVar("user_missile",user_missile+1)
	TNT1 A 0 A_SpawnItemEx("MainyuDeathExplosion4",random(0,128),0,random(16,100),frandom(1,8),0,frandom(1,8),random(0,360),0,200)
	2MA2 N 4 A_SpawnItemEx("MainyuDeathExplosion3",0,0,32,frandom(-6,6),frandom(-6,6),frandom(-6,6))
	Loop
  ActualDeath:
	TNT1 A 0 A_PlaySound("Mainyu/DeathExplode",7,1.0,0,ATTN_NONE)
	TNT1 AA 0 A_SpawnItemEx("MainyuDeathExplosion",0,0,32)
	TNT1 AA 0 A_SpawnItemEx("MainyuDeathExplosion2",0,0,32)
	TNT1 A 0 A_Quake(7,90,0,3000)
	TNT1 A 0 A_SpawnItemEx("SubliminationSword",0,0,8)
	TNT1 A 0 A_SpawnItemEx("DivineorDarkdivineArmor",0,0,64,random(1,8),0,2,random(0,360),0,0)
	TNT1 A 0 A_SpawnItemEx("DivineContract",0,0,64,random(1,8),0,2,random(0,360),0,0)
	TNT1 A 0 A_SpawnItemEx("NemesisMegaSphere",0,0,8,random(0,8),random(0,8),2,random(0,360),0,128)
	TNT1 A 0 A_SpawnItemEx("DemonicChalice",0,0,8,random(0,8),random(0,8),2,random(0,360),0,0)
	TNT1 A 0 A_SpawnItemEx("SkullOfPower",0,0,8,random(0,8),random(0,8),2,random(0,360),0,0)
	TNT1 AAAAA 0 A_SpawnItemEx("NemesisDemonicEnergy",0,0,8,random(0,8),random(0,8),2,random(0,360),0,80)
	TNT1 AA 0 A_SpawnItemEx("NemesisGreaterDemonicEnergy",0,0,8,random(0,8),random(0,8),2,random(0,360),0,60)
	TNT1 A 0 A_SpawnItemEx("Terminator",0,0,8,random(0,8),random(0,8),2,random(0,360),0,235)
	TNT1 A 0 A_SpawnItemEx("LegendaryInvulnerabilitySphere",0,0,64,random(1,8),0,2,random(0,360),0,64)
	TNT1 A 0 A_SpawnItemEx("LegendaryRune",0,0,64,random(1,8),0,2,random(0,360),0,64)
	TNT1 A 0 A_SpawnItemEx("LegendaryRune",0,0,64,random(1,8),0,2,random(0,360),0,64)
	TNT1 A 0 ACS_NamedExecuteAlways("ResetSky",0)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAA 3 A_SpawnItemEx("MainyuDeathExplosion4",random(0,128),0,random(16,100),frandom(1,8),0,frandom(1,8),random(0,360),0,120)
	TNT1 A 30 A_KillMaster
	Stop
  Null:
    TNT1 A 0 A_RemoveChildren(1)
	TNT1 A 1
	Stop
  }
}

ACTOR MReimuRageCheck : CustomInventory
{  
  -COUNTITEM
  +INVENTORY.QUIET
  +INVENTORY.UNDROPPABLE
  +INVENTORY.ALWAYSPICKUP
  +INVENTORY.AUTOACTIVATE
  inventory.maxamount 0
  States
  {
  Pickup:
	TNT1 A 1 ACS_NamedExecuteAlways("2huDoubleTeam")
	Stop
	}
}

ACTOR MainyuHornRodFX : DBishHornRodFXNotHoming { Damagetype "Mainyu" Speed 50 }

ACTOR MainyuRedDarkMatter : PainLordDarkMatter
{
  Speed 60
  +NOTIMEFREEZE
  Damagetype "Mainyu"
  States
  {
  Spawn:
	TNT1 AAA 0 A_SpawnItemEx("RedMatterSpark",0,0,0,random(-3,0),random(-2,2),random(-2,2))
	DMGR A 1 Bright
	TNT1 AAA 0 A_SpawnItemEx("RedMatterSpark",0,0,0,random(-3,0),random(-2,2),random(-2,2))
	DMGR A 1 Bright
	TNT1 AAA 0 A_SpawnItemEx("RedMatterSpark",0,0,0,random(-3,0),random(-2,2),random(-2,2))
	DMGR A 1 Bright
	TNT1 AAA 0 A_SpawnItemEx("RedMatterSpark",0,0,0,random(-3,0),random(-2,2),random(-2,2))
	DMGR B 1 Bright
	TNT1 AAA 0 A_SpawnItemEx("RedMatterSpark",0,0,0,random(-3,0),random(-2,2),random(-2,2))
	DMGR B 1 Bright
	TNT1 AAA 0 A_SpawnItemEx("RedMatterSpark",0,0,0,random(-3,0),random(-2,2),random(-2,2))
	DMGR B 1 Bright
	TNT1 AAA 0 A_SpawnItemEx("RedMatterSpark",0,0,0,random(-3,0),random(-2,2),random(-2,2))
	DMGR C 1 Bright
	TNT1 AAA 0 A_SpawnItemEx("RedMatterSpark",0,0,0,random(-3,0),random(-2,2),random(-2,2))
	DMGR C 1 Bright
	TNT1 AAA 0 A_SpawnItemEx("RedMatterSpark",0,0,0,random(-3,0),random(-2,2),random(-2,2))
	DMGR C 1 Bright
	Loop
  Death:
	TNT1 A 0
	TNT1 A 0 A_Playsound("PainLord/Explode1",7)
	TNT1 AAA 0 A_CustomMissile("MainyuRedDarkmatterKaboom", 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
	}
}

ACTOR RedMatterSpark : DarkMatterSpark
{
  +NOTIMEFREEZE
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1,"NULL")
	RPXS ABCDEFGHIJKL 1 Bright A_FadeOut(0.04)
	Stop	
  }
}

ACTOR RedShadowVaporSpawner
{
  +CLIENTSIDEONLY
  +NOINTERACTION
  +NOTIMEFREEZE
  Renderstyle None
  States
  {
  Spawn:
	TNT1 A 0 NoDelay A_JumpIf(ACS_ExecuteWithResult(304) == 1, "Null")
	TNT1 AAAAAAA 0 A_SpawnItemEx("RedShadowVapor",0,0,0,random(4,-4),random(4,-4),random(4,-4),random(0,359),32)
	PLAY A 3
	PLAY BCDEF 5
	Stop
	}
}

ACTOR RedShadowVapor : ShadowVaporDust
{
  +NOTIMEFREEZE
  States
  {
  Spawn:
	RPXS MNOPQRSTUVWXYZ 1 Bright A_FadeOut(0.018)
	RPXS ABC 2 A_FadeOut(0.018)
	Stop
	}
}

ACTOR MainyuRedDarkMatterVaporSpawner
{
  +NOTIMEFREEZE
  +NOINTERACTION
  +CLIENTSIDEONLY
  States
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1,"NULL")
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_SpawnItemEx("MainyuRedDarkMatterVapor",0,0,0,random(4,-4),random(4,-4),random(4,-4),random(0,359),32)
	TNT1 A 1
	Stop
	}
}

ACTOR MainyuRedDarkMatterVapor : PainLordVapor
{
  +NOTIMEFREEZE
  States
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_Playsound("PainLord/Explode2",7)
	RICE ABCDEF 3
	Stop
	}
}

ACTOR MainyuRedDarkmatterKaboom : Kaboom
{
  +NOTIMEFREEZE
  States
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1, "Toaster")
	FXPR A 1 Bright A_PlaySound("weapons/rocklx")
	FXPR ABBCDEFGHIJKLM 1 Bright A_FadeOut(0.05)
	Stop
  }
}

ACTOR MainyuPortalProjectile : GenericStrongOrb
{
  Speed 80
  Damage 12
  Scale 0.4
  +NOTIMEFREEZE
  +SEEKERMISSILE
  SeeSound "Spellbook/Fire1"
  Damagetype "Mainyu"
  States 
  {
  Spawn:
	TNT1 A 0 NoDelay A_Jump(256,"Spawn1","Spawn2","Spawn3","Spawn4")
  Spawn1:
	TNT1 A 0 A_SeekerMissile(1,1,SMF_LOOK|SMF_PRECISE)
	TNT1 A 0 A_Weave(2,2,2.0,2.0)
    CLBA D 1 Bright A_SpawnItemEx("MainyuPortalProjectileTrail")
    Loop
  Spawn2:
	TNT1 A 0 A_SeekerMissile(1,1,SMF_LOOK|SMF_PRECISE)
	TNT1 A 0 A_Weave(2,2,-2.0,-2.0)
    CLBA D 1 Bright A_SpawnItemEx("MainyuPortalProjectileTrail")
    Loop
  Spawn3:
	TNT1 A 0 A_SeekerMissile(1,1,SMF_LOOK|SMF_PRECISE)
	TNT1 A 0 A_Weave(2,2,2.0,-2.0)
    CLBA D 1 Bright A_SpawnItemEx("MainyuPortalProjectileTrail")
    Loop
  Spawn4:
	TNT1 A 0 A_SeekerMissile(1,1,SMF_LOOK|SMF_PRECISE)
	TNT1 A 0 A_Weave(2,2,-2.0,2.0)
    CLBA D 1 Bright A_SpawnItemEx("MainyuPortalProjectileTrail")
    Loop
  Death:
	TNT1 A 0
	TNT1 A 0 A_SpawnItem("WhiteProjExplode")
	TNT1 AAAAAAAAA 0 A_SpawnItemEx("WhiteProjParticleLarge",0,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),random(0,359))
    CLBA D 1 Bright A_FadeOut(0.2)
    Goto Death+2
  }
}

ACTOR MainyuPortalProjectileBig : MainyuPortalProjectile
{
  Speed 60
  Damage 20
  DeathSound "FANTASYSEAL"
  States 
  {
  Spawn:
	TNT1 A 0 NoDelay A_Jump(256,"Spawn1","Spawn2","Spawn3","Spawn4")
  Spawn1:
	TNT1 A 0 A_SeekerMissile(1,1,SMF_LOOK|SMF_PRECISE)
	TNT1 A 0 A_Weave(2,2,2.0,2.0)
    CLBB D 1 Bright A_SpawnItemEx("MainyuPortalProjectileTrailBig")
    Loop
  Spawn2:
	TNT1 A 0 A_SeekerMissile(1,1,SMF_LOOK|SMF_PRECISE)
	TNT1 A 0 A_Weave(2,2,-2.0,-2.0)
    CLBB D 1 Bright A_SpawnItemEx("MainyuPortalProjectileTrailBig")
    Loop
  Spawn3:
	TNT1 A 0 A_SeekerMissile(1,1,SMF_LOOK|SMF_PRECISE)
	TNT1 A 0 A_Weave(2,2,2.0,-2.0)
    CLBB D 1 Bright A_SpawnItemEx("MainyuPortalProjectileTrailBig")
    Loop
  Spawn4:
	TNT1 A 0 A_SeekerMissile(1,1,SMF_LOOK|SMF_PRECISE)
	TNT1 A 0 A_Weave(2,2,-2.0,2.0)
    CLBB D 1 Bright A_SpawnItemEx("MainyuPortalProjectileTrailBig")
    Loop
  Death:
	TNT1 A 0
	TNT1 A 0 A_Explode(128,128,0,0,100)
	TNT1 A 0 A_SpawnItem("WhiteProjExplodeLarge")
	TNT1 AAAAAAAAA 0 A_SpawnItemEx("WhiteProjParticleSuperLarge",0,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),random(0,359))
    CLBB D 1 Bright A_FadeOut(0.2)
    Goto Death+3
  }
}

ACTOR MainyuPortalProjectileTrail : BaseProjectileEffect
{
  +NOTIMEFREEZE
  Scale 0.4
  States
  {
  Spawn:
	TNT1 A 1
	CLBA D 1 Bright
	Goto Spawn2
  Spawn2:
	"####" "#" 1 Bright A_FadeOut(0.03)
	"####" "#" 0 A_SetScale(ScaleX-0.015)
    Loop
  }
}

ACTOR MainyuPortalProjectileTrailBig : BaseProjectileEffect
{
  +NOTIMEFREEZE
  States
  {
  Spawn:
	TNT1 A 1
	CLBB D 1 Bright
	Goto Spawn2
  Spawn2:
	"####" "#" 1 Bright A_FadeOut(0.05)
	"####" "#" 0 A_SetScale(ScaleX-0.025)
    Loop
  }
}

ACTOR MainyuSentientElectric
{
Monster
Radius 15
Height 30
+THRUACTORS
+LOOKALLAROUND
+BRIGHT
+NOTIMEFREEZE
+NOGRAVITY
+NOBLOOD
-COUNTKILL
Mass 1000000
DamageFactor "Legendary", 0.2
DamageFactor "PlayerNemesisPlasma", 0.2
Renderstyle Add
Obituary "%o was erased by Mainyu."
var int user_missile;
Tag "Mainyu Lightning Vessel"
States
{
  Spawn:
	MAIL XWVUTSRQPONMABCDEFGHIJKL 1 A_LookEx(LOF_NOJUMP,0,0,0,360)
  See:
	TNT1 A 0 A_JumpIf(user_missile >= 60,"Death")	 
	TNT1 A 0 A_SetUserVar("user_missile",user_missile+1)
	TNT1 A 0 A_FaceTarget
	TNT1 A 0 A_LookEx(LOF_NOJUMP,0,0,0,360)
	TNT1 A 0 A_MonsterRefire(0,2)
	TNT1 A 0 A_CustomMissile("MainyuSentientElectricProjectile",0,0,0,CMF_TRACKOWNER|CMF_CHECKTARGETDEAD)
	MAIL ABCDEFGHIJKL 1
	Loop
  Death:
	MAIL MNOPQRSTUVWX 2
	Stop
	}
}

ACTOR MainyuSentientElectricProjectile : BFlanLightningProj
{
  Radius 8
  Height 6
  Speed 50
  Damage 20
  +NOTIMEFREEZE
  -NODAMAGETHRUST
  +THRUSPECIES
  Scale 0.6
  Species "Touhou"
  DeathSound "weapons/devzap"
  Missiletype "MainyuElectricTrailSpawner"
  States
  {
  Spawn:
	MNLI ABCDE 1 Bright
	Loop
  Death:
	TNT1 AAA 0 A_SpawnItemEx("PurpleParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128)  
	TNT1 AAAA 0 A_CustomMissile("SmokeFX", 0, 0, random(0,360), 2, random(0,360))
	TNT1 AAAAAA 0 A_CustomMissile("PurpleKaboom4",0,0,random(0,360),2,random(0,360))
	BRE3 AB 4 Bright A_Explode(50,120)
	BRE3 CDEF 5 Bright
	stop
  }
}

actor MainyuElectricTrailSpawner
{
  +NOTIMEFREEZE
  +CLIENTSIDEONLY
  States
  {
  Spawn:
    TNT1 AA 0 A_SpawnItemEx("MainyuElectricTrail", Random(-10, 10), Random(-10, 10), Random(-10, 10), 0, 0, 0, 0, 160)
	Stop
  }
}

actor MainyuElectricTrail : ImpballTrail
{
  Scale 0.6
  Renderstyle Add
  Alpha 0.8
  +NOINTERACTION
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 1 A_JumpIf(ACS_ExecuteWithResult(304) == 1,"NULL")
    TNT1 A 0 A_Jump(256, "Puff1", "Puff2", "Puff3")
  Puff1:
    MNLI F 1 Bright A_FadeOut(0.1)
    Loop
  Puff2:
    MNLI G 1 Bright A_FadeOut(0.1)
    Loop
  Puff3:
    MNLI H 1 Bright A_FadeOut(0.1)
    Loop
  }
}
/*
ACTOR MainyuShockwaveSpawner : MReimuSwordSpawner1
{
  Speed 60
  -NOCLIP
  Obituary "%o was erased by Mainyu."
  MissileType "MainyuShockwaveExplode"
  States
  {
  Spawn: 
	TNT1 A 0
	//TNT1 A 0 A_JumpIf(user_loop >= 7,"Death")	 
	//TNT1 A 0 A_SetUserVar("user_loop",user_loop+1)
    TNT1 AAA 1
	TNT1 A 1 A_MissileAttack
    Loop
  Death:  
    TNT1 A 1
    Stop
  }
}

ACTOR MainyuShockwaveExplode : MReimuSword
{
  RenderStyle Add
  Scale 0.3
  Damagetype "Mainyu"
  Obituary "%o was erased by Mainyu."
  SeeSound "magicexplode"
  States
  {
  Spawn:
	TNT1 A 0 A_SpawnItemEx("NemesisWhiteParticleSpawner",0,0,0,0,0,0,0,128) 
	TNT1 AA 0 A_SpawnItemEx("NemesisRocketEx",0,0,0,random(-6,6),random(-6,6),random(5,15))
	TNT1 AAAAAAA 0 A_SpawnItemEx("WhiteNemesisKaboomNoSound",0,0,0,random(-6,6),random(-6,6),random(5,15))
    TNT1 A 1 A_Explode(250,250)
    Stop
	}
}
*/
ACTOR MainyuShockwaveExplodeBig : MReimuSword
{
  RenderStyle Add
  Scale 0.3
  Damagetype "Mainyu"
  Obituary "%o was erased by Mainyu."
  SeeSound "Mainyu/Floorshit"
  States
  {
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("MainyuFloorshitExplosion") 
	TNT1 A 0 A_Quake(10,55,0,2000,"")
	TNT1 A 0 A_Explode(2048,1000)
	TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("CyberNemesisGuruSphereSmoke",0,0,random(-70,40),frandom(-8,8),frandom(-8,8),frandom(-1,1),random(0,359),SXF_SETMASTER,0)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_SpawnItemEx("MainyuShockwaveRain",0,0,frandom(0,20),frandom(25,50),0,frandom(10,30),random(0,360))
    Stop
	}
}

ACTOR MainyuFloorshitExplosion : BaseProjectileEffect
{
  +NOTIMEFREEZE
  Scale 1.4
  States
  {
  Spawn:
	MAFX ABCDEFGHIJKLMNOPQRSTU 4 Bright
    Stop
	}
}

ACTOR MainyuShockwaveRain
{
  Projectile
  Radius 8
  Height 10
  +FORCERADIUSDMG
  +NOTIMEFREEZE
  -NOGRAVITY
  Renderstyle Add
  Damagetype "Mainyu"
  DeathSound "comet/explosion"
  States
  {
  Spawn:
	TNT1 A 1 A_SpawnItemEx("MainyuShockwaveRainTrail")
	Loop
  Death:
	TNT1 A 0 Bright A_Explode(128,200)
	TNT1 A 0 A_SpawnItemEx("NemesisWhiteParticleSpawner",0,0,0,0,0,0,0,SXF_CLIENTSIDE,0)
	NNCM DE 3 Bright
	TNT1 A 1 A_SpawnItemEx("NemesisLNCometDeath",0,0,0,0,0,0,0,SXF_CLIENTSIDE,0)
	Stop
	}
}

ACTOR MainyuShockwaveRainTrail : TrueNemesisHellionSmoke { Scale 0.2 }

ACTOR MainyuCometRain : MReimuDarkMatterRain
{
Renderstyle Add
States
{
  Spawn:
	TNT1 AAAAAAAAAAAAAAAAAAAA 1 A_Wander
	MMRA ABCDEFGHIJABCDEFGHIJ 2 Bright A_Wander
    TNT1 A 0 A_CustomMissile("FallingMainyuComet",-18,random(0,20),random(0,360),2)
	MMRA AAABBBCCC 1 Bright A_Wander
    TNT1 A 0 A_CustomMissile("FallingMainyuComet",-18,random(0,20),random(0,360),2)
	MMRA EEEFFFGGG 1 Bright A_Wander
    TNT1 A 0 A_CustomMissile("FallingMainyuComet",-18,random(0,20),random(0,360),2)
	MMRA HHHIIIJJJ 1 Bright A_Wander
	TNT1 A 0 A_CustomMissile("FallingMainyuComet",-18,random(0,20),random(0,360),2)
	MMRA AAABBBCCC 1 Bright A_Wander
    TNT1 A 0 A_CustomMissile("FallingMainyuComet",-18,random(0,20),random(0,360),2)
	MMRA EEEFFFGGG 1 Bright A_Wander
    TNT1 A 0 A_CustomMissile("FallingMainyuComet",-18,random(0,20),random(0,360),2)
	MMRA HHHIIIJJJ 1 Bright A_Wander
	TNT1 A 0 A_CustomMissile("FallingMainyuComet",-18,random(0,20),random(0,360),2)
  FadeOut:
	MMRA ABCDEFGHIJ 2 Bright A_FadeOut(0.06)
    Goto FadeOut
	}
}

ACTOR FallingMainyuComet : NemesisHKComet
{
  Radius 6
  Height 6
  Speed 5
  -FLOAT
  -NOGRAVITY
  +SPAWNCEILING
  +MTHRUSPECIES
  +DONTHURTSPECIES
  +DONTHARMSPECIES
  +FLOORCLIP
  +FORCERADIUSDMG
  Damagetype "Mainyu"
  DeathSound "magicexplode"
  States
  {
 Death:
  TNT1 A 0 A_SpawnItemEx("NemesisWhiteParticleSpawner",0,0,0,0,0,0,0,128) 
  TNT1 AAA 0 A_SpawnItemEx("NemesisRocketEx",0,0,0,random(-10,10),random(-10,10),random(6,18))
  TNT1 AAAAAAA 0 A_SpawnItemEx("WhiteNemesisKaboomNoSound",0,0,0,random(-10,10),random(-10,10),random(6,18))
  TNT1 A 0 A_Explode(300,300)
  NNCM DE 3 Bright
  TNT1 A 1 A_SpawnItemEx("NemesisLNCometDeath",0,0,0,0,0,0,0,SXF_CLIENTSIDE,0)
  Stop
  }
}

Actor MainyuStrikeBeam
{
  +FORCEYBILLBOARD
  +NOTIMEFREEZE
  +FORCERADIUSDMG
  +BRIGHT
  RenderStyle Add
  XScale 0.5
  YScale 5.0
  Alpha 0.0
  Damagetype "Mainyu"
  States
  {
  Spawn:
	SWHI AAAAAAAAAA 5 A_FadeIn(0.1)
	TNT1 AAA 0 A_SpawnItemEx("NemesisRocketEx",0,0,0,random(-10,10),random(-10,10),random(6,18))
	TNT1 AAAAAAA 0 A_SpawnItemEx("WhiteNemesisKaboomNoSound",0,0,0,random(-10,10),random(-10,10),random(6,18))
	TNT1 A 0 A_PlaySound("magicexplode",1,1.0,0,0.4)
	TNT1 A 0 A_Explode(300,300,0,0,200)
	SWHI A 1 A_FadeOut(0.05)
	Wait
	}
}

Actor MainyuBigStrikeBeam : MainyuStrikeBeam
{
  XScale 3.0
  States
  {
  Spawn:
	SWHI AAAAAAAAAA 15 A_FadeIn(0.1)
	TNT1 A 0 A_PlaySound("legendary/strike",1,1.0,0,ATTN_NONE)
	TNT1 A 0 A_Explode(8000,800,0,0,700)
	TNT1 AAAAAAAA 0 A_CustomMissile("NemesisCyberBouncyBFG",0,0,random(0,360),2,random(-5,30))
	TNT1 A 1 A_SpawnItem("NemesisDeathBall")
	SWHI A 1 A_FadeOut(0.05)
	Wait
	}
}

Actor MainyuStrikeBeamBlack : MainyuStrikeBeam
{
  RenderStyle Subtract
  States
  {
  Spawn:
	SWHI AAAAAAAAAA 5 A_FadeIn(0.1)
	TNT1 AAAAAAAAAA 0 A_SpawnItemEx("NemesisKaboom",0,0,0,random(-10,10),random(-10,10),random(6,18))
	TNT1 A 0 A_PlaySound("magicexplode",1,1.0,0,0.4)
	TNT1 A 0 A_Explode(300,300,0,0,200)
	TNT1 A 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,0,CMF_AIMDIRECTION|CMF_TRACKOWNER)
	TNT1 A 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,60,CMF_AIMDIRECTION|CMF_TRACKOWNER)
	TNT1 A 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,120,CMF_AIMDIRECTION|CMF_TRACKOWNER)
	TNT1 A 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,180,CMF_AIMDIRECTION|CMF_TRACKOWNER)
	TNT1 A 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,240,CMF_AIMDIRECTION|CMF_TRACKOWNER)
	TNT1 A 0 A_CustomMissile("NemesisCyberNobleBall3",0,0,300,CMF_AIMDIRECTION|CMF_TRACKOWNER)
	SWHI A 1 A_FadeOut(0.05)
	Wait
	}
}

Actor MainyuBigStrikeBeamBlack : MainyuStrikeBeamBlack
{
  XScale 3.0
  States
  {
  Spawn:
	SWHI AAAAAAAAAA 15 A_FadeIn(0.1)
	TNT1 A 0 A_PlaySound("NemesisExile/Explosion2",1,1.0,0,ATTN_NONE)
	TNT1 A 0 A_Explode(8000,800,0,0,700)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("PBlackHoleChunkSpawner")
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("PBlackHoleExplode")
	TNT1 A 0 A_SpawnItemEx("PBlackHoleShockwave")
	SWHI A 1 A_FadeOut(0.05)
	Wait
	}
}

Actor MainyuSwordProjectile : NemesisSoulBigBall
{
Speed 85
Radius 26
Height 6
Damage 60
Damagetype "Mainyu"
States
{
  Spawn:
	TNT1 A 0 A_SpawnItemEx("MainyuSwordProjectileTrail",-2,4,0,-3,3)
	TNT1 A 0 A_SpawnItemEx("MainyuSwordProjectileTrail",-2,-4,0,-3,-3)
	TNT1 A 0 A_SpawnItemEx("MainyuSwordProjectileTrail",-4,8,0,-5,5)
	TNT1 A 0 A_SpawnItemEx("MainyuSwordProjectileTrail",-4,-8,0,-5,-5)
	TNT1 A 0 A_SpawnItemEx("MainyuSwordProjectileTrail",-6,12,0,-7,7)
	TNT1 A 0 A_SpawnItemEx("MainyuSwordProjectileTrail",-6,-12,0,-7,-7)
	TNT1 A 1 A_SpawnItemEx("MainyuSwordProjectileTrail",0,0,0)
	Loop
  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(400,300,0,0,250)
	TNT1 A 25 Radius_Quake(5,25,0,20,0)
	Stop
	}
}

ACTOR MainyuSwordProjectileTrail : TrueNemesisHellionSmoke
{
States
  {
  Spawn:
	2HDT ABCDEFGHIJKL 2 Bright A_FadeOut(0.1,1)
	Stop
  }
}

ACTOR MainyuVoidTravelSlash : MainyuPortalProjectile
{
  Speed 45
  Damage 18
  XScale 0.5
  YScale 0.3
  +FORCERADIUSDMG
  SeeSound " "
  DeathSound "Mainyu/Slash"
  States 
  {
  Spawn:
    CLBA B 1 Bright A_SpawnItemEx("MainyuVoidTravelSlashTrail",0,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4))
    Loop
  Death:
	TNT1 A 0 A_SetScale(1.0,1.0)
	TNT1 A 0 A_Explode(80,100)
	TNT1 A 0 A_Jump(128,"Death2")
    MNS1 ABCDEFGHIJK 2 Bright
    Stop
  Death2:
    MNS2 ABCDEFGHIJK 2 Bright
    Stop
    }
}

ACTOR MainyuVoidTravelSlashTrail : BaseProjectileEffect
{
  +NOTIMEFREEZE
  Scale 0.1
  States
  {
  Spawn:
	TNT1 A 1
	CLBA B 1 Bright
	Goto Spawn2
  Spawn2:
	"####" "#" 1 Bright A_FadeOut(0.05)
	"####" "#" 0 A_SetScale(ScaleX-0.02)
    Loop
  }
}

ACTOR MainyuSublimination : PowerupGiver
{
  Inventory.MaxAmount 0
  Powerup.Type "PowerInvisibility"
  Powerup.Duration -30
  Powerup.Strength 100
  Powerup.Mode "Translucent"
  +INVENTORY.ADDITIVETIME
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
}

ACTOR MainyuSubliminationGiver : CustomInventory
{  
  -COUNTITEM
  +INVENTORY.QUIET
  +INVENTORY.UNDROPPABLE
  +INVENTORY.ALWAYSPICKUP
  +INVENTORY.AUTOACTIVATE
  inventory.maxamount 0
  States
  {
  Pickup:
	TNT1 A 1 A_SetBlend("White",1.0,25)
	TNT1 A 0 A_GiveInventory("MainyuSublimination",1)
	TNT1 A 0 A_PlaySound("exile/voidend",7,1.0,0,0.5)
	Stop
	}
}

ACTOR MainyuLeech : BulletPuff
{
  Damagetype "Touhou"
  Species "Touhou"
  +ALWAYSPUFF
  +PUFFONACTORS
  +PUFFGETSOWNER
  +NOTIMEFREEZE
  -THRUSPECIES
  States
  {
  Spawn:
	TNT1 A 1
	Stop
  XDeath:
	TNT1 A 0
	TNT1 A 1 A_GiveToTarget("Health",random(200,400))
	Stop
  }
}

ACTOR SuperMainyuLeech : MainyuLeech
{
  States
  {
  XDeath:
	TNT1 A 0
	TNT1 AAAA 0 A_SpawnItemEx("MainyuBlood1",random(-10,10),random(-10,10),random(-10,10),frandom(-2,2),frandom(-2,2),frandom(-2,2))
	TNT1 AAAA 0 A_SpawnItemEx("MainyuBlood2",random(-10,10),random(-10,10),random(-10,10),frandom(-2,2),frandom(-2,2),frandom(-2,2))
	TNT1 A 1 A_GiveToTarget("Health",random(200,400))
	Stop
  }
}

ACTOR MainyuBlood1
{
  +CLIENTSIDEONLY
  +NOINTERACTION
  +NOTIMEFREEZE
  Scale 1.5
  States
  {
  Spawn:
	BFB0 ABCDEFGHIJKLM 2
	Stop
	}
}

ACTOR MainyuBlood2 : MainyuBlood1
{
  States
  {
  Spawn:
	BFB9 ABCDEFGHIJKLMNOPQR 2
	Stop
	}
}

ACTOR MainyuShockPuff : MainyuLeech
{
  Renderstyle Subtract
  Alpha 1.0
  States
  {
  Spawn:
  XDeath:
	TNT1 A 0 NoDelay A_PlaySound("MReimu/TeleportIn",1)
	MNSK ABCDEFGH 1 Bright
	Stop
	}
}

ACTOR MainyuBarrier : BaseProjectileEffect
{
  Scale 0.8
  +NOTIMEFREEZE
  States
  {
  Spawn:
	MINB ABCDEFGHIJKL 4 Bright
	TNT1 A 0 A_SpawnItemEx("MainyuKanji")
	MINB MNOP 4 Bright
	TNT1 A 0 A_Playsound("uroboros/explode",4,1.0,0,0.1)
	MINB QQQQRRRRSSSSTTTT 1 Bright A_SetScale(ScaleX+0.05)
    Stop
  }
}

ACTOR MainyuKanji : BaseProjectileEffect
{
  Scale 1.0
  Alpha 0.2
  +NOTIMEFREEZE
  States
  {
  Spawn:
	MINB UUUUUUUU 1 Bright A_FadeIn(0.1)
	MINB U 8 Bright
	TNT1 A 0 A_Playsound("BFlan/Pain",4,1.0,0,0.1)
  SpawnLoop:
	TNT1 A 0 A_FadeOut(0.05)
	MINB U 1 Bright A_SetScale(ScaleX+0.1)
    Loop
  }
}

ACTOR MainyuWingsWhite1 : BaseProjectileEffect
{
  Renderstyle Add
  +NOTIMEFREEZE
  -FORCEXYBILLBOARD
  States
  {
  Spawn:
	MAWI ABCDEF 5 Bright
	MAWI F 1 Bright A_FadeOut(0.2)
    Goto Spawn+6
  }
}

ACTOR MainyuWingsWhite2 : BaseProjectileEffect
{
  Renderstyle Add
  +NOTIMEFREEZE
  -FORCEXYBILLBOARD
  Alpha 0.0
  States
  {
  Spawn:
	MAWI FFFFF 1 Bright A_FadeIn(0.2)
	MAWI EDCBA 5 Bright
    Stop
  }
}

ACTOR MainyuWingsBlack1 : MainyuWingsWhite1 { Renderstyle Subtract }
ACTOR MainyuWingsBlack2 : MainyuWingsWhite2 { Renderstyle Subtract }

ACTOR MainyuWingsWhiteAttack : MainyuWingsWhite1
{
  States
  {
  Spawn:
	MWI2 AAABBB 1 Bright A_FadeIn(0.25)
	MWI2 CDEFGHIJKLMNO 3 Bright
	TNT1 A 0 ThrustThingZ(0,40,0,0)
	MWI2 PQRSTU 3 Bright
    Stop
  }
}

ACTOR MainyuWhiteAttackCopy : BaseProjectileEffect
{
  Scale 0.7
  Renderstyle Normal
  States
  {
  Spawn:
	MAI8 AAABBCCDD 5
	TNT1 A 0 ThrustThingZ(0,40,0,0)
	MAI8 EEEEEEEEE 2
	TNT1 A 1 A_SpawnItemEx("MReimuCastEffect2",0,0,50)
    Stop
  }
}

ACTOR MainyuWingsBlackAttack : MainyuWingsWhiteAttack { Renderstyle Subtract }

ACTOR MainyuBlackAttackCopy : MainyuWhiteAttackCopy
{
  States
  {
  Spawn:
	2MA8 AAABBCCDD 5
	TNT1 A 0 ThrustThingZ(0,40,0,0)
	2MA8 EEEEEEEEE 2
	TNT1 A 1 A_SpawnItemEx("MReimuCastEffect2Black",0,0,50)
    Stop
  }
}

ACTOR MainyuWhitePortal : BaseProjectileEffect
{
  Renderstyle Add
  +NOTIMEFREEZE
  -FORCEXYBILLBOARD
  Scale 0.8
  Alpha 0.0
  States
  {
  Spawn:
	MLIU ABCDEFGHIJ 2 Bright A_FadeIn(0.1)
	MLIU KLMNOPQRST 2 Bright A_FadeOut(0.1)
    Stop
  }
}

ACTOR MainyuVoidTravelEffect : BaseProjectileEffect
{
  Scale 1
  +NOTIMEFREEZE
  States
  {
  Spawn:
	MND3 ABCDEFGHIJKLMNOPQRST 1 Bright
    Stop
  }
}

ACTOR MainyuVoidTravelFake : BaseProjectileEffect
{
  Scale 1
  +NOTIMEFREEZE
  States
  {
  Spawn:
	MAIV ABCDEFGHIJKLMNOP 3 Bright
    Stop
  }
}

ACTOR MainyuVoidTravelFakeBlack : MainyuVoidTravelFake
{
  Renderstyle Subtract
  States
  {
  Spawn:
	MAIV ABCDEFGHIJKLMNOP 3 Bright
    Stop
  }
}

ACTOR MainyuDeathExplosion : BaseProjectileEffect
{
  Scale 1.5
  +NOTIMEFREEZE
  States
  {
  Spawn:
	MNDX ABCDEFGHIJKLMNOPQRSTU 4 Bright
    Stop
  }
}

ACTOR MainyuDeathExplosion2 : BaseProjectileEffect
{
  Scale 1.5
  +NOTIMEFREEZE
  States
  {
  Spawn:
	MND3 ABCDEFGHIJKLMNOPQRST 4 Bright
    Stop
  }
}

ACTOR MainyuDeathExplosion3 : BaseProjectileEffect
{
  Scale 0.6
  +NOTIMEFREEZE
  States
  {
  Spawn:
	MAIL ABCDEFGHIJKLMNOPQRSTUVWX 1 Bright
    Stop
  }
}

ACTOR MainyuDeathExplosion4 : BaseProjectileEffect
{
  +NOTIMEFREEZE
  States
  {
  Spawn:
	TNT1 A 0 NoDelay A_PlaySound("uroboros/explode",1,1.0,0,0.6)
	MND2 ABCDEFGHIJK 2 Bright
    Stop
  }
}

ACTOR MainyuFloorshitCharge : BaseProjectileEffect
{
  +NOTIMEFREEZE
  Scale 0.1
  States
  {
  Spawn:
	MAFC ABCDEFGHIJ 2 Bright A_SetScale(ScaleX+0.065)
	MAFC ABCDEFGHIJ 2 Bright A_FadeOut(0.2)
    Stop
  }
}

ACTOR MainyuLightning 
{
  +NOGRAVITY
  +NOCLIP
  +NOTIMEFREEZE
  Renderstyle Add
  Height 32
  Radius 16
  Scale 2
  States
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_PlaySoundEx("BFlan/Lightning",7)    
	TNT1 A 0 Radius_Quake(175,8,512,1024,0)
	TNT1 AAA 0 A_CustomMissile("SmokeFX3",0,0,random(0,360),2,random(0,360))
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("WhiteLightningSpark",0,0,0,random(1,10),0,random(1,10),random(0,359),129)
	DV10 ABCBCAB 3 Bright
	Stop
    }     
}

ACTOR MainyuSparkle
{
  +NOINTERACTION
  +CLIENTSIDEONLY
  +NOTIMEFREEZE
  +BRIGHT
  Renderstyle Add
  Alpha 1.0
  Scale 0.7
  States
  {
  Spawn:
	MAIP ABCDEFGHIJKLMNOPQRSTUVWXYZ 1
	Stop
	}
} 

ACTOR MainyuFire : MainyuSparkle
{
  Renderstyle Subtract
  States
  {
  Spawn:
	MAIF ABCDEFGHIJKLMNOPQRSTUVW 1
	Stop
	}
}

ACTOR MainyuSparkleSpawner
{
  +NOINTERACTION
  +CLIENTSIDEONLY
  +ISMONSTER
  +NOTIMEFREEZE
  States
  {
  Spawn:
	TNT1 A 0
    TNT1 A 2 A_Warp(AAPTR_MASTER,0,0,0,0,WARPF_ABSOLUTEANGLE|WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1, "Toaster")
    TNT1 AA 0 A_SpawnItemEx("MainyuSparkle",random(-80,80),random(-80,80),random(40,60),0,0,frandom(-2,-0.5))
    Loop
  Toaster:
    TNT1 A 2 A_Warp(AAPTR_MASTER,0,0,0,0,WARPF_ABSOLUTEANGLE|WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 0, "Spawn")
	Loop
	}
}

ACTOR MainyuFireSpawner : MainyuSparkleSpawner
{
  States
  {
  Spawn:
	TNT1 A 0
    TNT1 A 2 A_Warp(AAPTR_MASTER,0,0,0,0,WARPF_ABSOLUTEANGLE|WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1, "Toaster")
    TNT1 AA 0 A_SpawnItemEx("MainyuFire",random(-80,80),random(-80,80),random(40,60))
    Loop
	}
}