/*

==MANTIS BUNKER==
The only melee option of the Blastmaster Mk.2, the Mantis Bunker
is a pair of miniature pile bunkers, designed to pummel close range
targets into the dust. As the weapon builds heat, the "fists" grow
hotter as well, not only causing more physical damage, the attacks
becoming increasingly more painful, aiding in staggering and stunning
targets.

When fully overheated, the Mantis Bunker will forcibly eject the 
two pile bunkers at high velocity, causing severe damage to anything
unfortunate enough to be in its path. The weapon regenerates the twin
bunkers to be reused again after the excess heat is vented out.
*/

ACTOR MantisBunker : Weapon
{
	Weapon.SelectionOrder 60
	Weapon.SlotNumber 1
	weapon.bobstyle alpha
	weapon.bobrangex 0.2
	weapon.bobrangey 0.2
	weapon.bobspeed 2
	Inventory.PickupMessage "You got the mantis bunker!"
	obituary "%o was pummeled by %k's lobster gun."
	Inventory.RestrictedTo "Blastmaster"
	+WEAPON.AMMO_OPTIONAL
	+WEAPON.ALT_AMMO_OPTIONAL
	+NOAUTOAIM
	Tag "Mantis Bunker"
	states
	{
	Select:
		TNT1 A 0
        TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_Raise
        TNT1 A 1 A_Raise
		goto ready
	Ready:
		BMST A 2
		TNT1 A 0 A_playsound ("Mantisbunker/raise",0)
		BNKE ABCDE 1 
		BNKE FGHIJKLMN 1 A_weaponready (WRF_NOBOB)
		goto realready
	Deselect:
		TNT1 A 0
		TNT1 A 0 A_jumpifhealthlower (1, "deadlower")
		TNT1 A 0 A_takeinventory ("secretaction", 99)
		TNT1 A 0
		TNT1 A 0 A_playsound ("Mantisbunker/lower",0)
		BNKE LJIHGFECBA 1
		BMST A 5
	holster:
        TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_lower
        TNT1 A 1 A_lower
		loop
	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 AAAAAAAAAAAAA 0 A_lower
		TNT1 A 1 A_lower
		wait	
	Realready:
		TNT1 A 0
		TNT1 A 0 A_jumpifinventory ("BMoverheat",1,"lockdown")
		BNKR A 1 A_weaponready
		TNT1 A 0 A_jumpifinventory ("BMoverheat",1,"lockdown")
		loop
	lockdown:
		TNT1 A 0
		BNKR A 3 A_weaponready (WRF_NOPRIMARY)
		TNT1 A 0 A_firecustommissile ("smashersmokespawner",0,0,0,0,0,0)
		BNKR A 3 A_weaponready (WRF_NOPRIMARY)
		TNT1 A 0 A_jumpifinventory ("BMoverheat",1,"lockdown")
		goto realready
	Fire:
		TNT1 A 0 
		TNT1 A 0 A_jumpifinventory ("BMoverheat",1,"lockdown")
		TNT1 A 0 a_jumpifinventory ("BMheat",156,"HotPunch")
		TNT1 A 0 A_jumpifinventory ("BMheat",91,"PowerPunch")
		TNT1 A 0 A_playsound ("mantisbunker/leftpunch", CHAN_WEAPON)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		BNKR B 1 offset (0,33)
		BNK4 A 1 offset (0,32)
		BNK4 B 1 A_FireCustomMissile("MantisPunch",0,0,-2)
		BNK4 C 2 
		TNT1 A 0 A_giveinventory ("BMheat",3)
		TNT1 A 0 A_playsound ("mantisbunker/rightpunch", CHAN_WEAPON)
		BNK4 D 1
		BNK4 E 1 offset (0,33)
		BNK4 F 1 offset (0,32)
		BNK4 G 2 A_FireCustomMissile("MantisPunch",0,0,2)
		TNT1 A 0 A_giveinventory ("BMheat",3)
		TNT1 A 0 A_jumpifinventory ("BMOverheat",1,"finisherpunch")
		TNT1 A 0 A_refire
		BNKR JKLM 1
		goto realready


	PowerPunch:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("BMheat",156,"HotPunch")
		TNT1 A 0 A_playsound ("mantisbunker/Lv2Left", CHAN_WEAPON)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		BNKR B 1 offset (0,33)
		BNK1 A 1 offset (0,32)
		BNK1 B 1 A_FireCustomMissile("MantisPowerPunch",0,0,-2)
		TNT1 A 0 a_playsound ("Blastmaster/Mediumheat",6)
		BNK1 C 2 
		TNT1 A 0 A_FireCustomMissile("MantisExtraPunch",0,0,-2)
		TNT1 A 0 A_giveinventory ("BMheat",3)
		TNT1 A 0 A_playsound ("mantisbunker/Lv2Right", CHAN_WEAPON)
		BNK1 D 1
		TNT1 A 0 a_playsound ("Blastmaster/Mediumheat",6)
		BNK1 E 1 offset (0,33)
		BNK1 F 1 offset (0,32)
		BNK1 G 2 A_FireCustomMissile("MantisPowerPunch",0,0,2)
		TNT1 A 0 A_FireCustomMissile("MantisExtraPunch",0,0,2)
		TNT1 A 0 A_giveinventory ("BMheat",3)
		TNT1 A 0 A_jumpifinventory ("BMOverheat",1,"finisherpunch")
		TNT1 A 0 A_refire
		BNKR JKLM 1
		goto realready


	HotPunch:
		TNT1 A 0
		TNT1 A 0 A_playsound ("mantisbunker/Lv3Left", CHAN_WEAPON)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		BNKR B 1 offset (0,33)
		BNK2 A 1 offset (0,32)
		BNK2 B 1 A_FireCustomMissile("HotMantisPunch",0,0,-2)
		TNT1 A 0 a_playsound ("Blastmaster/HighHeat",6)
		BNK2 C 2 
		TNT1 A 0 A_FireCustomMissile("MantisExtraPunch",0,0,-2)
		TNT1 A 0 A_giveinventory ("BMheat",2)
		TNT1 A 0 A_playsound ("mantisbunker/Lv3Right", CHAN_WEAPON)
		BNK2 D 1
		BNK2 E 1 offset (0,33)
		BNK2 F 1 offset (0,32)
		TNT1 A 0 a_playsound ("Blastmaster/HighHeat",6)
		BNK2 G 2 A_FireCustomMissile("HotMantisPunch",0,0,2)
		TNT1 A 0 A_giveinventory ("BMheat",2)
		TNT1 A 0 A_jumpifinventory ("BMOverheat",1,"finisherpunch")
		TNT1 A 0 A_refire
		BNKR JKLM 1
		TNT1 A 0 A_jumpifinventory ("BMOverheat",1,"finisherpunch")
		goto realready


	Finisherpunch:
		TNT1 A 0
		BNKR N 3 A_playsound ("mantisbunker/superwindup", 0)
		BNKR O 6
		BNKR O 2
		BNK3 AABB 1
		TNT1 A 0 A_playsound ("Blastmaster/Lightheat",0)
		TNT1 A 0 A_playsound ("mantisbunker/superpunch", CHAN_WEAPON)
		TNT1 A 0 A_firecustommissile ("FlyingBunker",0,0,3)
		TNT1 A 0 A_firecustommissile ("FlyingBunker",0,0,-3)
		TNT1 A 0 A_Quake(3, 8, 0, 32)
		TNT1 A 0 a_recoil (6)
		BNKR TUV 2
		BNKR V 4
		BNKR WXY 2
		BNKR A 1
		goto lockdown

	//VENT ATTACKS------------------------------------------------------------------
	Altfire:
		TNT1 A 0
		BNKR A 2 A_weaponready (WRF_NOFIRE)
		TNT1 A 0 A_jumpifinventory ("BMoverheat",1,"OverHeatFire")
		TNT1 A 0 A_jumpifinventory ("BMheat",156,"RedGrenade")
		TNT1 A 0 A_jumpifinventory ("BMheat",91,"YellowMachineGun")
		TNT1 A 0 A_jumpifinventory ("BMheat",1,"BlueFire")
		goto realready

	//Blue Fire (Tier one)----------------------------------------------------------
	BlueFire:
		TNT1 A 0 A_playsound ("BlastMaster/BlueFireStart",0)
		TNT1 A 0 A_playsound ("BlastMaster/BlueFireLoop",6,1,1)
	BlueFireLoop:
		TNT1 A 0 A_gunflash
		TNT1 A 0 A_takeinventory ("BMheat",2)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		TNT1 A 0 A_giveinventory ("BlastMasterVented",1)
		TNT1 A 0 A_recoil (0.10)
		TNT1 A 0 Bright A_FireCustomMissile ("BlueVentFire",Frandom(-5, 5), 0, random(-1,1), random(-2,-1), 0, Frandom(-2, 2))
		BNKR A 0 A_jumpifinventory ("SuperVenter",1,"SuperBlueFire")
		BMV1 AB 1 bright
		TNT1 A 0 A_jumpifinventory ("BMHeat",1,"BlueFireLoop")
		TNT1 A 0 A_playsound ("BlastMaster/BlueFireEnd",6)
		goto VentFinish
	SuperBlueFire:
		TNT1 A 0
		TNT1 A 0 A_FireCustomMissile ("BlueVentEmber1",Frandom(-5, 5), 0, random(-4,4), random(1,4), 0, Frandom(-5, 5))
		TNT1 A 0 A_FireCustomMissile ("BlueVentEmber2",Frandom(-5, 5), 0, random(-4,4), random(1,4), 0, Frandom(-5, 5))
		TNT1 A 0 Bright A_FireCustomMissile ("BlueVentFire",Frandom(-9, 9), 0, random(-3,3), random(-2,-1), 0, Frandom(-4, 4))
		TNT1 A 0 A_playsound ("BlastMaster/PowerFire",0)
		BMV1 AB 1 bright
		TNT1 A 0 A_jumpifinventory ("BMHeat",1,"BlueFireLoop")
		TNT1 A 0 A_playsound ("BlastMaster/BlueFireEnd",6)
		goto VentFinish

	//Yellow Machine Gun (Tier two)--------------------------------------------------
	YellowMachineGun:
		TNT1 A 0 A_gunflash
		TNT1 A 0 A_takeinventory ("BMheat",4)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		TNT1 A 0 A_giveinventory ("BlastMasterVented",1)
		TNT1 A 0 A_playsound ("BlastMaster/YellowShot",6)
		TNT1 A 0 A_Quake(1, 2, 0, 32)
		BNKR A 0 A_jumpifinventory ("SuperVenter",1,"YellowHitScan")
		ESHG B 0 Bright A_FireCustomMissile("YellowVentBullet",Frandom(-2, 2), 0, 0, random(-1,1), 0, Frandom(-2, 2))
		BMV1 CD 1 bright
		BNKR A 1
		TNT1 A 0 A_jumpifinventory ("BMHeat",1,"YellowMachineGun")
		goto VentFinish
	YellowHitScan:
		ESHG B 0 Bright A_FireBullets (3.5, 2.0, -1, 6, "YellowCAPuff",FBF_NORANDOM) 
		BMV1 C 1 bright
		TNT1 A 0 A_playsound ("BlastMaster/PowerGun",6)
		BMV1 D 1 bright
		BNKR A 1
		TNT1 A 0 A_jumpifinventory ("BMHeat",1,"YellowMachineGun")
		goto VentFinish

	//Red Grenade (Tier three)--------------------------------------------------------
	RedGrenade:
		TNT1 A 0 A_gunflash
		TNT1 A 0 A_playsound ("BlastMaster/RedGrenade",6)		
		TNT1 A 0 A_takeinventory ("BMheat",999)
		TNT1 A 0 A_giveinventory ("BlastMasterVented",1)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		TNT1 A 0 A_Quake(2, 6, 0, 32)
		BNKR A 0 A_jumpifinventory ("SuperVenter",1,"SuperGrenade")
		ESHG B 0 Bright A_FireCustomMissile("RedGrenade")
		BMV1 EFGHHIIJJKKLL 1 bright
		BNKR A 3
		goto VentFinish
	SuperGrenade:
		ESHG B 0 Bright A_FireCustomMissile("SuperRedGrenade")
		BMV1 EFGHH 1
		TNT1 A 0 A_playsound ("BlastMaster/PowerGrenade",6)		
		BMV1 IIJJKKLL 1 bright
		BNKR A 3
		goto VentFinish

		
	
	VentFinish:
		BNKR A 3
		BMP1 ABCC 2
		TNT1 A 0 A_takeinventory ("BlastMasterFired",99)
		TNT1 A 0 A_takeinventory ("BlastMasterVented",99)
		TNT1 A 0 A_playsound ("BlastMaster/PumpDown",0)
		BMP1 DEFFG 2 A_FireCustomMissile ("BlastMasterSmoker",0,0,6,6)
		TNT1 A 0 A_playsound ("BlastMaster/PumpUp",0)
		BMP1 CBA 2
		BNKR A 1
		goto realready

	//Super Flamer (Overheat)--------------------------------------------------------
	OverHeatFire:
		TNT1 A 0 A_takeinventory ("BlastMasterFired",99)
		TNT1 A 0 A_takeinventory ("BlastMasterVented",99)
		TNT1 A 0 A_playsound ("BlastMaster/BlueFireStart",0)
		TNT1 A 0 A_playsound ("BlastMaster/RedFireStart",0)
		TNT1 A 0 A_playsound ("BlastMaster/RedFireLoop",6,1,1)
	OverHeatFireLoop:
		TNT1 A 0 A_gunflash
		TNT1 A 0 Bright A_FireCustomMissile ("RedVentFire",Frandom(-5, 5), 0, random(-1,1), random(-2,-1), 0, Frandom(-2, 2))
		TNT1 A 0 A_takeinventory ("BMOverHeat",1)
		TNT1 A 0 A_recoil (0.15)
		BNKR A 0 A_jumpifinventory ("SuperVenter",1,"SuperRedFire")
		BMV1 MN 1 bright
		TNT1 A 0 A_refire ("OverHeatCheck")
		TNT1 A 0 A_playsound ("BlastMaster/RedFireEnd",6)	
		BNKR A 0 A_jumpifinventory ("SuperVenter",1,"RedFinisherCheck")
		BNKR A 6 
		BNKR A 6 A_weaponready (WRF_NOPRIMARY)
		goto LockDown	
	OverHeatCheck:
		TNT1 A 0 A_jumpifinventory ("BMOverHeat",1,"OverHeatFireLoop")
		TNT1 A 0 A_playsound ("BlastMaster/RedFireEnd",6)	
		goto VentFinish

	SuperRedFire:
		TNT1 A 0
		TNT1 A 0 A_FireCustomMissile ("RedVentEmber1",Frandom(-5, 5), 0, random(-4,4), random(1,4), 0, Frandom(-5, 5))
		TNT1 A 0 A_FireCustomMissile ("RedVentEmber2",Frandom(-5, 5), 0, random(-4,4), random(1,4), 0, Frandom(-5, 5))
		TNT1 A 0 Bright A_FireCustomMissile ("RedVentFire",Frandom(-9, 9), 0, random(-3,3), random(-2,-1), 0, Frandom(-4, 4))
		TNT1 A 0 A_playsound ("BlastMaster/PowerFire",0)
		BMV1 MN 1 bright
		TNT1 A 0 A_refire ("OverHeatCheck")
		TNT1 A 0 A_playsound ("BlastMaster/RedFireEnd",6)
		goto RedFinisherCheck
	RedFinisherCheck:
		TNT1 A 0 A_jumpifinventory ("BMOverHeat",60,"SuperFinisher")
		goto LockDown
	SuperFinisher:
		TNT1 A 0 A_gunflash
		TNT1 A 0 A_playsound ("BlastMaster/RedGrenade",6)		
		TNT1 A 0 A_takeinventory ("BMOverHeat",60)
		BNKR A 0 A_jumpifinventory ("SuperVenter",1,"SuperGrenade")
		ESHG B 0 Bright A_FireCustomMissile("RedGrenade")
		BMV1 EFGHHIIJJKKLL 1 bright
		BNKR A 6
		goto LockDown
	

	Flash:
		TNT1 A 2 Bright A_Light(3)
		TNT1 A 2 Bright A_Light2
		TNT1 A 2 Bright A_Light1
		Goto LightDone
	}
}


//===================================================================
//===================================================================
//THE ATTACKS
//===================================================================
//===================================================================


actor MantisPunch : fastprojectile
{
	Projectile
	speed 80
	damage (15)
	+BLOODLESSIMPACT
	+thruspecies
	+dontblast
	+dontreflect
	+bright
	renderstyle add
	alpha 0.60
	species "player"
	height 6
	radius 10
	decal CADecal
	translation "0:255=%[0.05,0.17,0.45]:[0.57,0.88,1]" 
	mass 50000
	states
	{
	Spawn:
		TNT1 A 1
		stop
	Death:
		TNT1 A 0
		TNT1 A 2
		TNT1 A 0 A_PlaySound("pipe/wall", CHAN_AUTO)
		TNT1 AAA 0 a_spawnitemex ("BMBulletSparkBlue",4,0,0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 radius_quake (1,3,0,8,0)
		TNT1 A 5 
		stop
	Xdeath:
		TNT1 A 0
		TNT1 A 2
		TNT1 A 0 A_PlaySound("punch/hit", CHAN_AUTO)
		TNT1 A 0 radius_quake (1,7,0,8,0)
		MNSP ABCD 1
		stop
	}
}

actor MantisPowerPunch : MantisPunch
{
	scale 2
	damage (20)
	translation "0"
	states
	{
	Death:
		TNT1 A 0
		TNT1 A 2
		TNT1 A 0 A_PlaySound("pipe/wall", CHAN_AUTO)
		TNT1 AAA 0 a_spawnitemex ("BMBulletSparkYellow",4,0,0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 radius_quake (1,3,0,8,0)
		TNT1 A 5 
		stop
	}
}

actor MantisExtraPunch : MantisPunch
{
	damage (1)
	states
	{
	Death:
		TNT1 A 0
		TNT1 A 5 
		stop
	Xdeath:
		TNT1 A 0
		TNT1 A 2
		stop
	}
}



actor HotMantisPunch : MantisPunch
{
	+forcepain
	scale 1
	renderstyle add
	alpha 0.70
	damage (25)
	translation "212:223=178:191", "162:162=175:175", "226:226=172:172"
	//translation "0:255=%[0.77,0.065,0]:[0.86,0.32,0.30]" 
	states
	{
	Death:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 0 A_PlaySound("pipe/wall", CHAN_AUTO)
		TNT1 AAA 0 a_spawnitemex ("BMBulletSparkRed",4,0,0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,0,SXF_NOCHECKPOSITION)
		TNT1 AA 0 Bright A_SpawnItemEx("RedVentEmber3",frandom(-7,7),frandom(-7,7),frandom(-8,8),frandom(-1,1),frandom(-1,1),frandom(0,1),0,SXF_TRANSFERTRANSLATION)
		TNT1 AA 0 Bright A_SpawnItemEx("RedVentEmber4",frandom(-8,8),frandom(-8,8),frandom(-7,7),frandom(-1,1),frandom(-1,1),frandom(0,1),0,SXF_TRANSFERTRANSLATION)
		TNT1 A 0 radius_quake (1,3,0,8,0)
		TNT1 A 5 
		stop
	Xdeath:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 0 A_PlaySound("punch/hit", CHAN_AUTO)
		TNT1 A 0 A_SpawnItemEx("MiniLavaLazerExplosion",0,0,0,0,0,0,0,SXF_TRANSFERTRANSLATION)
		TNT1 AAA 0 Bright A_SpawnItemEx("RedVentEmber3",frandom(-7,7),frandom(-7,7),frandom(-8,8),frandom(-1,1),frandom(-1,1),frandom(0,1),0,SXF_TRANSFERTRANSLATION)
		TNT1 AAA 0 Bright A_SpawnItemEx("RedVentEmber4",frandom(-8,8),frandom(-8,8),frandom(-7,7),frandom(-1,1),frandom(-1,1),frandom(0,1),0,SXF_TRANSFERTRANSLATION)
		TNT1 A 0 radius_quake (2,7,0,8,0)
		RIVP A 2 BRIGHT
		RIVP BCDE 1 BRIGHT
		stop
	}
}



ACTOR FlyingBunker : SharpPellet
{
	Speed 95
	Radius 7
	Height 8
	PROJECTILE
	damage (90)
	xscale 0.35
	yscale 0.15
	DeathSound "RivetImpact"
	MissileType "RivetFlyRing"
	decal CADecal
	MissileHeight 8
    +BLOODSPLATTER
	translation "224:231=81:81", "161:161=92:92", "162:162=95:95", "161:161=93:93", "163:163=104:104", "164:164=109:109", "165:165=110:110", "166:166=5:5", "167:167=5:5", "41:47=7:7", "232:239=5:8"
	States
	{
	Spawn:
		BBLT A 1 Bright
		Loop
	Death:
		TNT1 A 0
		TNT1 A 0 A_SetScale (0.65,0.65)
		TNT1 A 0 A_SetTranslucent(0.8)
		TNT1 A 0 Thing_SetTranslation(0, 0)
		RIVP A 2 BRIGHT
		RIVP BCDE 1 BRIGHT
		Stop
	}
}


actor MiniLavaLazerExplosion : LavaLazerExplosion
{
	scale 0.10
}
