/////////////////////////
// PROTOMAN BOSS FIGHT //
/////////////////////////

actor ProtomanBoss
{
//$Category MM8BDM-Bosses
Height 46
Radius 34
Scale 2.5
Obituary "%o was destroyed by \cgProtoMan\c-."
Translation "192:192=87:87", "198:198=42:42"
+INVULNERABLE
Health 1000
mass 99999999
damagefactor "Misc", 0.0
damagefactor "Quick", 0.0
damagefactor "Buster", 1.2
painchance 100
Speed 7
Damage 0
MONSTER
+THRUSPECIES
//-ISMONSTER
//+NORADIUSDMG
//+FLOAT
floatspeed 0
-COUNTKILL
-SOLID
-CANPASS
+NOBLOOD
+LOOKALLAROUND
+SLIDESONWALLS
+NOPAIN
//+NODAMAGE
//MaxStepHeight 0
//gravity 1.5
-DROPOFF
states
{
	Spawn:
	PROM AK 10 A_Look
	loop
	Spawn2:
	PROM AK 10
	loop
	Seek:
	PROM A 1 A_LookEx(0, 0, 0, 0, 0, "See")
	loop
	See:
	PROM A 0 A_Stop
	PROM A 0 A_FaceTarget
	PROM E 0 A_TakeInventory("StopShield",999)
	PROM L 10 A_TakeInventory("CutterFlag",999)
	PROM A 0 A_ChangeFlag("INVULNERABLE", 0)
	PROM A 0 A_Jump(256, "Hop", "Hop", "Dash", "ShieldToss")
	Goto ShieldToss
	
	Hop:
	PROM L 0 A_GiveInventory("StopShield",1)
	PROM L 3 A_FaceTarget 
	PROM N 3 A_ChangeVelocity(3,0,15,CVF_RELATIVE|CVF_REPLACE)
	PROM N 1 //A_GiveInventory("StopShield",1)
	PROM E 0 A_FaceTarget
	PROM E 0 A_PlaySoundEx("misc/devilfire", "Voice", 0, 1)
	PROM O 5 A_CustomMissile("ProtoBossBuster", 48, 0, 0)
	PROM E 0 A_FaceTarget
	PROM E 0 A_PlaySoundEx("misc/devilfire", "Voice", 0, 1)
	PROM O 5 A_CustomMissile("ProtoBossBuster", 48, 0, 0)
	Falling:
	PROM E 0 A_TakeInventory("StopShield",999)
	PROM N 1 A_Jumpif(floorz==z, "HopLand")
	loop
	HopLand:
	PROM E 0 A_PlaySoundEx("misc/protoland", "Voice", 0, 1)
	PROM L 2 A_Stop
	PROM A 0 A_GiveInventory("CutterFlag",1)
	PROM A 0 A_JumpIfInventory("CutterFlag", 4, "HopEnd")
	PROM A 0 A_JumpIfInventory("CutterFlag", 3, "Jump")
	Goto Hop
	HopEnd:
	PROM L 18 A_TakeInventory("StopShield",999)
	Goto Seek
	Jump:
	PROM L 3 A_FaceTarget 
	PROM N 3 A_ChangeVelocity(10,0,18,CVF_RELATIVE|CVF_REPLACE)
	PROM N 1 A_GiveInventory("StopShield",1)
	PROM E 0 A_FaceTarget
	PROM E 0 A_PlaySoundEx("misc/devilfire", "Voice", 0, 1)
	PROM O 2 A_CustomMissile("ProtoBossBuster", 48, 0, -32)
	PROM E 0 A_PlaySoundEx("misc/devilfire", "Voice", 0, 1)
	PROM O 2 A_CustomMissile("ProtoBossBuster", 48, 0, -16)
	PROM E 0 A_PlaySoundEx("misc/devilfire", "Voice", 0, 1)
	PROM O 2 A_CustomMissile("ProtoBossBuster", 48, 0, -8)
	PROM E 0 A_PlaySoundEx("misc/devilfire", "Voice", 0, 1)
	PROM O 2 A_CustomMissile("ProtoBossBuster", 48, 0, 0)
	PROM E 0 A_PlaySoundEx("misc/devilfire", "Voice", 0, 1)
	PROM O 2 A_CustomMissile("ProtoBossBuster", 48, 0, 8)
	PROM E 0 A_PlaySoundEx("misc/devilfire", "Voice", 0, 1)
	PROM O 2 A_CustomMissile("ProtoBossBuster", 48, 0, 16)
	PROM E 0 A_PlaySoundEx("misc/devilfire", "Voice", 0, 1)
	PROM O 2 A_CustomMissile("ProtoBossBuster", 48, 0, 32)
	Goto Falling
	
	Dash:
	PROM L 15 A_FaceTarget
	PROM A 0 A_PlaySoundEx("weapon/tengudash", "Voice", 0, 1)
	PROM A 0 A_FaceTarget
	DashLoop:
	PROM B 0 A_ChangeVelocity(27,0,0,CVF_RELATIVE|CVF_REPLACE)
	PROM B 0 A_FaceTarget
	PROM P 1 A_JumpIfCloser(64, "DashPass")
	PROM B 0 A_ChangeVelocity(27,0,0,CVF_RELATIVE|CVF_REPLACE)
	PROM B 0 A_FaceTarget
	PROM P 1 A_JumpIfCloser(64, "DashPass")
	PROM B 0 A_SpawnItemEx("ProtoDust", -32, 0, 0)
	loop
	DashPass:
	PROM P 0 ACS_ExecuteAlways(6,0,8)
	PROM PPPPPPPPPPPPPPP 1 A_ChangeVelocity(30,0,0,CVF_RELATIVE|CVF_REPLACE)
	DashHit:
	PROM L 35 A_Stop
	Goto Seek
	
	ShieldToss:
	PROM L 7 A_FaceTarget
	PROM L 1 A_GiveInventory("StopShield",1)
	PROM L 0 A_FaceTarget
	PROM Q 10 A_SpawnItemEx("ProtoShieldAttack", 0, 0, 32, 23, 0, 5, random(-30,30))
	PROM L 10
	PROM B 0 ACS_ExecuteAlways(6,0,9)
	PROM A 0 A_JumpIfInventory("AtomicFireAmmo", 1, "BluffChance")
	ShieldCharge:
	PROM L 40 A_PlaySoundEx("weapon/pcharge", "Voice", 0, 1)
	PROM A 0 A_PlaySoundEx("weapon/pshot", "Voice", 0, 1)
	ShieldShot:
	PROM M 1 ACS_ExecuteAlways(6,0,10)
	PROM M 16 A_SpawnItemEx("ProtoShotBoss", 0, 0, 32, 50, 0, 0, 0)
	PROM L 12 A_GiveInventory("AtomicFireAmmo",1)
	Goto ChaseShield
	BluffCharge:
	PROM L 20 A_PlaySoundEx("weapon/pcharge", "Voice", 0, 1)
	PROM LLLLLL 5 A_FaceTarget
	PROM A 0 A_FaceTarget
	PROM A 0 A_PlaySoundEx("weapon/pshot", "Voice", 0, 1)
	PROM M 16 A_SpawnItemEx("ProtoShotBoss", 0, 0, 32, 50, 0, 0, 0)
	PROM L 12
	Goto ChaseShield
	BluffChance:
	PROM F 0 A_Jump(128,"BluffCharge")
	Goto ShieldCharge
	ChaseShield:
	PROM L 1 ACS_ExecuteAlways(6,0,10)
	PROM A 0 A_PlaySoundEx("weapon/tengudash", "Voice", 0, 1)
	PROM A 0 ACS_ExecuteAlways(6,0,11)
	Chasing:
	PROM PP 1 A_ChangeVelocity(30,0,0,CVF_RELATIVE|CVF_REPLACE)
	PROM P 0 A_SpawnItemEx("ProtoDust", -32, 0, 0)
	PROM P 0 A_SpawnItemEx("ProtoDamager")
	loop
	
	Death:
	PROM H 1 A_Jumpif(floorz==z, "Dying")
	loop
	Dying:
	PROM H 0 SetPlayerProperty(1,1,4)
	PROM H 0 A_FaceTarget
	PROM HHHHHHHH 1 Thing_SetTranslation(0, 0)
	PROM H 0 Thing_Remove(501)
	PROM IJ 30
	PROM J 0
	Dead:
	PROM IJ 30
	loop
	
	Fallen:
	PROM R -1
	stop
	Leave:
	TFOG B 0 A_ChangeFlag("NOGRAVITY",1)
	TFOG BBBAAACCC 1
	TFOG A 65 A_ChangeVelocity(0,0,13,CVF_RELATIVE|CVF_REPLACE)
	stop
	}
}

actor ProtoDamager
{
+MISSILE
-SOLID
+NOINTERACTION
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 1 A_Explode(10, 40, 0)
	stop
	}
}

actor ProtoShieldAttack
{
+MISSILE
//+ISMONSTER
//+ACTIVATEMCROSS
damagetype "Quick"
+DOOMBOUNCE
-NOGRAVITY
height 34
radius 34
scale 2.5
bouncefactor 0.4
//+RIPPER
+BOUNCEONACTORS
+DONTRIP
-SHOOTABLE
+LOOKALLAROUND
health 99999999
painchance 256
damage (20)
Translation "192:192=87:87", "198:198=42:42"
//seesound "weapon/deflect"
//bouncesound "weapon/deflect"
Obituary "%o was destroyed by \cgProtoMan\c-."
States
{
	Spawn:
	Death:
	PROS B 0 Thing_ChangeTID(0,501)
	PROS B 3 A_SetAngle(angle + 45)
	PROS B 0 A_ChangeFlag("SHOOTABLE",1)
	loop
	Pain.ProtoBuster:
	PROS B 0 A_ChangeFlag("SHOOTABLE",0)
	PROS B 1 A_ClearTarget
	PROS BBBB 1 A_LookEx(0,0,0,0,360,"Shoot")
	Goto Spawn
	Shoot:
	PROS B 0 A_PlaySoundEx("item/protoreflect", "Voice", 0, 1)
	PROS B 0 A_FaceTarget
	PROS B 1 A_CustomMissile("ProtoShotBoss", 32, 0, 0)
	Goto Spawn
}
}

actor ProtoBossShieldGiver : CustomInventory
{
+INVENTORY.AUTOACTIVATE
	States
	{
	Pickup:
	PROC J 0 A_SpawnItemEx("ProtoShieldX",23,-17,8,momx, momy, momz, 0, SXF_ABSOLUTEMOMENTUM|SXF_TRANSFERTRANSLATION, 0)
	PROC J 0 A_SpawnItemEx("ProtoShieldFX",23,-17,8,momx, momy, momz, 0, SXF_ABSOLUTEMOMENTUM|SXF_TRANSFERTRANSLATION, 0)
	stop
	}
}

actor ProtoShotBoss : ProtoShot3
{
Speed 45
Translation "192:192=108:108", "198:198=110:110"
Damage (10)
+RIPPER
radius 20
height 50
Damagetype "ProtoBuster"
scale 3.2
	States
	{
	Spawn:
	CHBU AAABBBCCCDDD 1 A_SpawnItemEx("ProtoShotBossTrail")
	loop
	}
}

actor ProtoShotBossTrail
{
Translation "192:192=108:108", "198:198=110:110"
renderstyle Stencil
stencilcolor "Green"
alpha 0.7
scale 3.2
+NOINTERACTION
	States
	{
	Spawn:
	TNT1 A 1
	Fade:
	CHBU A 1 A_FadeOut(0.1)
	loop
	}
}

actor ProtoDust : HyperStormDust
{
Scale 1.0
}

actor ProtoBossBuster : MegaShot
{
Speed 42
}
