ACTOR Tatsuya : GenericBoss
{
Speed 20
Health 4000
DamageFactor 0.75
DamageFactor "Legendary", 0.4
DropItem "BossLifeEssence" 255 25
DropItem "BossArmorBonusMax" 255 1
DropItem "GreaterDemonicEnergy" 128 200
DropItem "DemonicChalice" 128
DropItem "LifeLegendaryRune" 128
DropItem "ExoticWeaponEnhancerModuleGiver" 100
Obituary "%o was mesmerized by Tatsuya."
Tag "\c[a6]Tatsuya\c-"
+MISSILEMORE
var int user_music;
var int user_missile;
States
{
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("Disable2hu") == 1, "Remove")
  Idle:
    TOJI ABCDEF 3 A_Look
    Loop
  Remove:
	TNT1 A 1
	TNT1 A 0 A_SpawnItemEx("Cacodemon~",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
	TNT1 A 0 A_ChangeFlag("COUNTKILL", FALSE)
	TNT1 A 0
	Stop
  See:
    TOJI ABC 3 A_Chase
	TNT1 A 0 A_Jump(32,"Teleport")
	TOJI DEF 3 A_Chase
	TNT1 A 0 A_Jump(32,"Teleport")
    Loop
  Teleport:
	TOJ2 E 2 Bright A_UnSetShootable
	TNT1 A 0 A_PlaySound("boss/teleport",0)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("TatsuyaTeleportParticle1",random(0,10),0,random(0,64),frandom(3,5),0,0,random(0,360))
	TOJ2 FFFFFFFFFF 1 Bright A_FadeOut(0.1,0)
	TNT1 A 10
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_Wander
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_Wander
	TNT1 A 10
	TNT1 A 0 A_PlaySound("boss/teleport",0)
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("TatsuyaTeleportParticle2",random(60,80),0,random(0,64),frandom(-5,-3),0,0,random(0,360))
	TOJ2 FFFFFFFFFF 1 Bright A_FadeIn(0.1)
	TOJ2 F 10
	TOJ2 E 2 Bright A_SetShootable
	Goto See
  Pain:
    TOJI G 4 A_Pain
    Goto See
  Missile:
    TNT1 A 0 A_Jump(160,"SpearCast","SpawnerOrbs","MiniDTBFG")
	TNT1 A 0 A_Jump(256,"YellowSpear","SpearCastBallPit")
    Goto See
  SpearCast:
	TNT1 A 0 A_PlaySound("Tatsuya/SpearCast")
    TOJ2 NOPQRS 4
	TNT1 A 0 A_ChangeFlag("NOGRAVITY",0)
	TNT1 A 0 A_ChangeFlag("NOPAIN",1)
	TNT1 A 0 A_ChangeFlag("FLOAT",0)
	TOJ2 TUVW 4
	TNT1 A 0 A_Quake(2,120,256,1024)
	TNT1 A 0 A_SetUserVar("user_missile",0)
  SpearCastLoop:
	TNT1 A 0 A_JumpIf(user_missile >= 40,"SpearCastEnd")
	TNT1 A 0 A_SetUserVar("user_missile",user_missile+1)
	TNT1 AAAAAAA 0 A_CustomMissile("SmallGreenOrb",30,0,random(0,359),CMF_OFFSETPITCH,frandom(-5,5))
	TOJ2 W 3
	Loop
  SpearCastEnd:
	TNT1 A 0 A_ChangeFlag("NOGRAVITY",1)
	TNT1 A 0 A_ChangeFlag("FLOAT",1)
	TNT1 A 0 A_ChangeFlag("NOPAIN",0)
	TNT1 A 0 ThrustThingZ(0,30,0,1)
	TOJ2 "X" 10
	TNT1 A 0 A_Stop
	Goto See
  SpawnerOrbs:
	TOJ2 ABC 5
	TOJ2 DCDCDC 6 A_CustomMissile("TatsuyaSpawnerOrb",32)
	Goto See
  MiniDTBFG:
	TOJ2 HI 8
	TOJ2 JKLJKL 8 A_CustomMissile("TatsuyaMiniDTBFG",32,0,random(-15,15))
	Goto See
  SpearCastBallPit:
	TNT1 A 0 A_PlaySound("Tatsuya/SpearCast")
    TOJ2 NOP 5
	TOJ3 ABCDE 5
	TNT1 A 0 A_SetUserVar("user_missile",0)
  SpearCastBallPitLoop:
	TNT1 A 0 A_JumpIf(user_missile >= 10,"See")
	TNT1 A 0 A_SetUserVar("user_missile",user_missile+1)
	TNT1 A 0 A_PlaySound("remishot")
	TOJ3 E 7 A_CustomMissile("GreenBallPitOrb",80,0,random(-30,30),CMF_OFFSETPITCH,frandom(-5,5))
	Loop
  YellowSpear:
    TNT1 A 0 A_Playsound("remsee",7,1,0,ATTN_NONE)
	TOJ3 FGHIJJJKLMMMN 6
	TNT1 A 0 A_CustomMissile("TatsuyaYellowSpear",32,0,0)
	TOJ3 OPQ 4
	TOJ3 RST 6
	Goto See
  Death:
    TOJI GHI 20
	TNT1 A 0 Radius_Quake(20,8,0,12,0)
    TNT1 A 0 A_Explode(260,200)
	TNT1 A 0 A_NoBlocking
    TNT1 A 0 A_Scream
	TNT1 A 0 A_Playsound("BFlan/LightningExp",7)
	TNT1 A 0 A_SpawnItem("PlayerDTBFGEx",0,30)
	TNT1 AAAAAA 0 A_SpawnItemEx("GreenParticleSpawner", 0, 0, random(30,50), 0, 0, 0, 0, 128)  
	TNT1 AAAAAA 0 A_CustomMissile("SmokeFX",random(30,50), 0, random(0,360), 2, random(0,360))
	TNT1 AAAAAAAAA 0 A_CustomMissile("Kaboom11",random(30,50),0,random(0,360),2,random(0,360))
	TNT1 A 0 A_SpawnItemEx("BossDeathExplode",0,0,32)
	TNT1 AAAAAAAAAAA 0 A_SpawnItemEx("2huBossDeathFlame",0,0,20,random(-3,3),random(-3,3),random(-3,3))
	TNT1 AAAAAAAAAAA 1 A_SpawnItemEx("2huBossDeathFlame3",0,0,random(5,55),random(-15,15),random(-15,15),random(-15,30))
	Stop
  }
}

ACTOR SmallGreenOrb : GenericWeakOrb
{
  Speed 20
  damage (random(10,30))
  SeeSound "remishot"
  States
  {
  Spawn:
    CLBA H 1 Bright A_SpawnItemEx("GreenProjParticleLarge",0,0,0,0,frandom(-1,1),frandom(-1,1),random(0,359))
	TNT1 A 0 A_SpawnItemEx("GreenProjParticleLarge",0,0,0,0,frandom(-1,1),frandom(-1,1),random(0,359))
    Loop
  Death:
	TNT1 A 0
	TNT1 AAAAAAAAA 0 A_SpawnItemEx("GreenProjParticle",0,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),random(0,359))
    CLBA H 1 Bright A_FadeOut(0.2)
    Goto Death+1
  }
}

ACTOR GreenBallPitOrb : GenericSuperOrb
{
  Speed 20
  Damage (random(50,120))
  +SEEKERMISSILE
  States
  {
  Spawn:
    CLBB H 1 Bright A_SpawnItemEx("GreenProjParticleSuperLarge2",0,0,0,0,frandom(-1,1),frandom(-1,1),random(0,359))
	TNT1 A 0 A_SpawnItemEx("GreenProjParticleSuperLarge2",0,0,0,0,frandom(-1,1),frandom(-1,1),random(0,359))
    CLBB H 1 Bright A_SpawnItemEx("GreenProjParticleSuperLarge2",0,0,0,0,frandom(-1,1),frandom(-1,1),random(0,359))
	TNT1 A 0 A_SpawnItemEx("GreenProjParticleSuperLarge2",0,0,0,0,frandom(-1,1),frandom(-1,1),random(0,359))
	TNT1 A 0 A_SeekerMissile(2,4)
    Loop
  Death:
	TNT1 A 0
	TNT1 A 0 A_Explode(100,200)
	TNT1 A 0 A_SpawnItemEx("GreenProjExplodeLarge")
	TNT1 AAAAAAAAA 0 A_SpawnItemEx("GreenProjParticleSuperLarge",0,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),random(0,359))
    CLBB H 1 Bright A_FadeOut(0.2)
    Goto Death+3
  }
}

ACTOR TatsuyaYellowSpear : FastProjectile
{
  Radius 9
  Height 12
  Scale 1
  Speed 80
  Renderstyle Add
  SeeSound "BIGMISSILE"
  DeathSound "BFlan/LightningExp"
  +FORCERADIUSDMG
  Damagetype "Touhou"
  MissileType "TatsuyaSpearTrail"
  MissileHeight 8
  States
  {
  Spawn:
    CLBB F 1 Bright
    Loop
  Death:
	TNT1 A 0
	TNT1 A 0 A_Explode(100,100)
	TNT1 A 0 A_SpawnItem("LegAnniDTBFGEx",0,-10)
	TNT1 A 0 Radius_Quake(20,8,0,12,0)
	LFE3 AB 4 Bright A_Explode(260,200)
	LFE3 CDEF 5 Bright
    Stop
  }
}

ACTOR TatsuyaSpearTrail : BaseProjectileEffect
{
  Scale 1.3
  States
  {
  Spawn:
    TNT1 A 0
	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1,"NULL")
  Fade:
	CLBA F 1 Bright A_FadeOut(0.05)
	TNT1 A 0 A_SetScale(ScaleX-0.05)
    Loop
  }
}

ACTOR TatsuyaSpawnerOrb : GenericStrongOrb
{
  Speed 20
  SeeSound "remishot"
  States
  {
  Spawn:
    CLBA HHHHHHHHHH 1 Bright A_SpawnItemEx("GreenProjParticleSuperLarge",0,0,0,0,frandom(-1,1),frandom(-1,1),random(0,359))
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,random(0,360),CMF_AIMDIRECTION,random(-10,10))
    Loop
  Death:
	TNT1 A 0 A_SpawnItemEx("GreenProjExplode")
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,0,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,30,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,60,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,90,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,120,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,150,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,180,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,210,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,240,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,270,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,300,CMF_AIMDIRECTION)
	TNT1 A 0 A_CustomMissile("SmallGreenOrb",0,0,330,CMF_AIMDIRECTION)
	TNT1 AAAAAAAAA 0 A_SpawnItemEx("GreenProjParticleLarge",0,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),random(0,359))
    CLBA H 1 Bright A_FadeOut(0.2)
    Goto Death+13
	}
}

ACTOR TatsuyaMiniDTBFG : LesserCardinalMiniDTBFG
{
DamageType "Touhou"
Obituary "%o was mesmerized by Tatsuya." 
SeeSound "LesserCardinal/BFGFire"
States
{
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_PlaySoundEx("LesserCardinal/BFGIdle","Voice",1)
    CGS1 ABCDABCD 1 Bright A_SpawnItemEx("BFGTrailParticleGreen",Random(-12,12),Random(-12,12),Random(12,22),Random(-2,2),Random(-2,2),Random(-2,2),Random(-20,20),128)
    TNT1 A 0 A_CustomMissile("TatsuyaBFGProjectileAttack",Random(-10,10),0,0,CMF_TRACKOWNER)
    Loop  
  Death:
    TNT1 A 0
	TNT1 A 0 A_SetTranslucent(0.75,1)
	TNT1 A 0 Radius_Quake(5,60,0,10,0)
	TNT1 A 0 A_Explode(40,200)
	CGS1 A 6 Bright A_SpawnItemEx("BFGShockwave", 0, 0, 15, 0, 0, 0, 0, 128)
	TNT1 A 0 A_Explode(40,200)
	CGS1 B 6 Bright A_SpawnItemEx("BFGShockwave", 0, 0, 15, 0, 0, 0, 0, 128)
	TNT1 A 0 A_Explode(40,200)
	CGS1 C 6 Bright A_SpawnItemEx("BFGShockwave", 0, 0, 15, 0, 0, 0, 0, 128)
	TNT1 A 0 A_Explode(40,200)
	CGS1 D 6 Bright A_SpawnItemEx("BFGShockwave", 0, 0, 15, 0, 0, 0, 0, 128)
	TNT1 A 0 A_Explode(240,240)
	TNT1 A 0 A_StopSoundEx("Voice")
	TNT1 A 0 Radius_Quake(20,12,0,12,0)
	TNT1 A 0 A_PlaySound("weapons/bfg95explode")
	TNT1 A 0 A_SpawnItemEx("BFGShockwave", 0, 0, 0, 0, 0, 0, 0, 128)
	TNT1 A 0 A_SpawnItemEx("GreenParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128)
	TNT1 AAA 0 A_CustomMissile("Kaboom13", 0, 0, random(0,360), 2, random(0,360))
	TNT1 A 0 A_SetScale(1.0)
    BFE3 ABCDEF 4 Bright
    Stop
    }
}

ACTOR TatsuyaBFGProjectileAttack : LesserCardinalBFGProjectileAttack
{
Obituary "%o was mesmerized by Tatsuya." 
MissileType "TatsuyaLightningProjectile"
}

ACTOR TatsuyaLightningProjectile : LesserCardinalLightningProjectile
{
DamageType "Touhou"
Projectile
States
{
  Spawn:
	TATL ABCABC 2 Bright A_SpawnItemEx("TatsuyaLiteTrail")
  Death:
	TATL DEFGHIJKLMNO 1 Bright
	Stop
	}
}

ACTOR TatsuyaLiteTrail
{
  +CLIENTSIDEONLY
  +NOINTERACTION
  Renderstyle Add
  Alpha 0.67
   States
   {
   Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1,"NULL")
	TATL ABC 3 Bright
	Stop
	}
}

ACTOR TatsuyaTeleportParticle1 : BaseProjectileParticleLarge
{
  Scale 0.07
  States
  {
  Spawn:
	CLBA H 1 Bright A_FadeOut(0.05)
	Wait
	}
}

ACTOR TatsuyaTeleportParticle2 : TatsuyaTeleportParticle1
{
  Alpha 0.0
  States
  {
  Spawn:
	CLBA HHHHHHHHHHHHHHHHHHHH 1 Bright A_FadeIn(0.05)
	Stop
	}
}