actor Daibatana : weapon replaces BFG9000
{
	Weapon.SelectionOrder 20
	Weapon.AmmoUse 1
	weapon.ammouse2 1
	Weapon.AmmoGive 4
	Weapon.AmmoType1 "BatPower"
	Weapon.AmmoType2 "BatPower"
	Weapon.SlotNumber 7
	scale 0.80
	+WEAPON.AMMO_OPTIONAL
	+floatbob
	+WEAPON.ALT_AMMO_OPTIONAL
	Inventory.PickupMessage "You got the Daibatana!"
	Obituary "%k made %o their bitch."
	states
	{
	Spawn:
		DBPU A -1 bright
		loop
	Select:
		TNT1 A 0 a_raise
		TNT1 A 1 a_raise
		loop
	ready:
		TNT1 A 0
		TNT1 A 0 a_playsound ("daibatana/draw",0)
		DBDW BDF 2
		DBDW G 2
		TNT1 A 4
		DBID CBA 2
	realready:
		DBID A 1 a_weaponready
		loop
	deselect:
		TNT1 A 0
		TNT1 A 0 a_jumpifhealthlower (1, "deadlower")
		DBID ABC 1
		TNT1 A 1
		DBDW GFEC 2
		TNT1 A 0 a_playsound ("daibatana/sheathe",0)
		DBDW BA 2 
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		wait	
	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		wait	
	fire:
		DBID B 2
		TNT1 A 0 a_jumpifinventory ("BatPower", 1, "powerfire")		
		DBES ABC 2
		DBWS D 2
		TNT1 A 0 a_playsound ("daibatana/weakballhit",0)
		TNT1 A 0 a_firecustommissile ("batmelee",0,0)
		DBWS E 2 a_firecustommissile ("batball",0,0)
		DBWS G 1
		TNT1 A 6 
		DBID BA 2
		goto realready
	powerfire:
		TNT1 A 0
		TNT1 A 15 A_Quake(1, 12, 0, 5)
		DBES A 3 bright a_quake (2, 10, 0, 5)
		DBES BC 2 bright
		TNT1 A 0 a_playsound ("kick/attack",0)
		TNT1 A 0 a_playsound ("daibatana/spreadswing",0)
		TNT1 A 0 A_Quake(3, 8, 0, 5)		
		DBPS A 1 bright
		DBPS B 1 bright a_firecustommissile ("supermelee",0,0,0,0,0,0)
		TNT1 A 0 a_playsound ("particlesmasher/altfire",0)
		TNT1 A 0 a_playsound ("particlesmasher/explode",0)
		TNT1 A 0 A_PlaySound("daibatana/supermiss",0)
		DBPS B 0 bright a_firecustommissile ("SuperBatBall", 0,1,0,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",-17,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",-14,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",-11,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",-8,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",-5,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",-2,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",2,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",5,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",8,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",11,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",14,0,0,0)
		DBPS B 0 A_FireCustomMissile("spreadbatball",17,0,0,0)
		DBPS D 1 bright 
		DBPS F 1 bright 
		TNT1 A 14
		TNT1 A 5 a_refire 
		DBID BA 2
		goto realready
	altfire:
		TNT1 A 0 a_jumpifinventory ("BatPower", 1, "rapidball")
		DBID B 2
		DBES ABC 2
		TNT1 A 0 a_playsound ("daibatana/swing",0)
		DBWS D 2
		DBWS E 1 a_firecustommissile ("batmelee",0,0)
		//DBWS F 1 
		DBWS G 1
		TNT1 A 6
		TNT1 A 6 a_refire
		DBID BA 2
		goto realready
	rapidball:
		DBID B 2 
		TNT1 A 2
		TNT1 A 15 A_Quake(1, 12, 0, 5)
		DBES A 3 bright a_quake (2, 10, 0, 5)
		DBES A 1 bright
		DBES ABC 1 bright
		TNT1 A 0 a_playsound ("daibatana/swing",0)
		TNT1 A 0 a_playsound ("daibatana/fastpowerswing1",0)
		DBNS A 2 bright
		TNT1 A 0 a_firecustommissile ("batmelee",0,0)
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS B 1 bright a_firecustommissile ("railball",0,1)
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS C 1 bright
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS D 1 bright
		TNT1 A 1
		DBBS ABC 1 bright
		TNT1 A 0 a_playsound ("daibatana/swing",0)
		TNT1 A 0 a_playsound ("daibatana/fastpowerswing2",0)
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS E 2 bright
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS F 1 bright
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS G 1 bright
		TNT1 A 1
		DBES A 1 bright
		DBES ABC 1 bright
		TNT1 A 0 a_playsound ("daibatana/swing",0)
		TNT1 A 0 a_playsound ("daibatana/fastpowerswing1",0)
		DBNS A 2 bright
		TNT1 A 0 a_firecustommissile ("batmelee",0,0)
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS B 1 bright a_firecustommissile ("railball",0,0)
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS C 1 bright
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS D 1 bright
		TNT1 A 1
		DBBS ABC 1 bright
		TNT1 A 0 a_playsound ("daibatana/swing",0)
		TNT1 A 0 a_playsound ("daibatana/fastpowerswing2",0)
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS E 2 bright
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS F 1 bright
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS G 1 bright
		TNT1 A 1
		DBES A 1 bright
		DBES ABC 1 bright
		TNT1 A 0 a_playsound ("daibatana/swing",0)
		TNT1 A 0 a_playsound ("daibatana/fastpowerswing1",0)
		DBNS A 2 bright
		TNT1 A 0 a_firecustommissile ("batmelee",0,0)
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS B 1 bright a_firecustommissile ("railball",0,0)
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS C 1 bright
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS D 1 bright
		TNT1 A 1
		DBBS ABC 1 bright
		TNT1 A 0 a_playsound ("daibatana/swing",0)
		TNT1 A 0 a_playsound ("daibatana/fastpowerswing2",0)
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS E 2 bright
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS F 1 bright
		TNT1 AAA 0 a_firecustommissile ("lilbatball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		TNT1 AAAAAAAA 0 a_firecustommissile ("railball",Frandom(-6,9),0,0,0,0,Frandom(-6,10))
		DBNS G 1 bright
		TNT1 A 1
		DBID BA 2
		goto realready
	meleebackswing:
		DBBS ABC 2
		TNT1 A 0 a_jumpifinventory ("BatPower", 20, "PowerMeleeBackSwing")
		TNT1 A 0 a_playsound ("daibatana/swing",0)
		DBWS K 2
		DBWS L 1 a_firecustommissile ("batmelee")
		DBWS M 1 
		TNT1 A 6
		TNT1 A 6 a_weaponready
		DBID BA 2
		goto realready
	powermeleebackswing:
		TNT1 A 0 a_playsound ("daibatana/swing",0)
		DBNS E 2
		DBNS F 1 a_firecustommissile ("supermelee")
		DBNS G 1
		DBNS H 1
		TNT1 A 7
		TNT1 A 6 a_weaponready
		DBID BA 2
		goto realready
	}
}

actor SuperBatBall 
{
	Radius 18
	Height 13
	Speed 35
	damage (580)
    Decal Scorch
	species "Player"
	projectile
	+thruspecies
	+forceradiusdmg
	+bright
	+LOOKALLAROUND
	+forcexybillboard
	+ripper
	damagetype daibatana
	reactiontime 25
	scale 1.5
	DeathSound "daibatana/SuperBallEnd"
	States
	{
	spawn:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("ringeffect")
        TNT1 A 0 A_PlaySound("daibatana/SuperBallStart")
		TNT1 A 0 a_playsound ("daibatana/SuperBallLoop",6,1,1)		
		DBPJ AB 2
		DBPJ AB 2
		TNT1 A 0 a_changeflag ("ripper", 0)
	flight:
		DBPJ AB 2
		DBPJ AB 2
		TNT1 A 0 a_countdown
		goto flight
	death:
		TNT1 A 0
		TNT1 A 0 a_stopsound (6)
		TNT1 A 0 radius_quake (3,5,0,15,0)
		TNT1 A 0 a_playsound ("particlesmasher/explode",0)
		TNT1 A 0 a_playsound ("buster/explosion",0)		
		TNT1 A 0 A_Explode (600, 550,1,0,250)
		TNT1 A 0 A_Spawnitemex ("ballexplosion")
		stop
	}
}		

actor ballexplosion
{
	Radius 18
	Height 13
	Speed 35
	damage 0
    Decal Scorch
	species "Player"
	+thruspecies
	+forceradiusdmg
	+bright
	+nointeraction
	+LOOKALLAROUND
	+clientsideonly 
	+forcexybillboard
	+ripper
	+nodamagethrust
	renderstyle add
	alpha 0.95
	scale 5
	states
	{
	spawn:
		TNT1 A 0
		TNT1 A 0
		EXP5 ACEGIKLNOQRSTUVWXYZ 1
		TNT1 A 0
		stop
	}
}
actor ringeffect
{
	+nointeraction
	+clientsideonly
	scale 2
	speed 55
	renderstyle add
	alpha 0.90
	states
	{
	spawn:
		TRNG GFEDCBA 2
		TNT1 A 0
		stop
	}
}


actor batball
{
	Radius 8
	Height 8
	Speed 30
	Damage 4
	Projectile
	scale 0.60
	species "Player"
	+thruspecies
	+RANDOMIZE
	+noextremedeath
	States
	{
	spawn:	
		NBAL ABCD 2
		NBAL ABCD 2
		NBAL ABCD 2
		TNT1 A 0 a_gravity
	falling:
		NBAL ABCD 2
		loop
	xdeath:
		TNT1 A 0
		TNT1 A 0 a_playsound ("daibatana/ballhit",0)
		TNT1 A 1 a_spawnitemex("ballrebound",0,0,0,Frandom(2,10),Frandom(2,10),5, SXF_NOCHECKPOSITION)
		stop
	death:
		TNT1 A 0
		TNT1 A 1 a_spawnitemex("ballrebound",0,0,0,Frandom(2,10),Frandom(2,10),5, SXF_NOCHECKPOSITION)
		stop
	}
}

actor lilbatball : batball
{
	scale 0.50
	speed 45
	states
	{
	spawn:
		NBAL ABCD 2
		NBAL ABCD 2
		NBAL ABCD 2
		TNT1 A 0 a_gravity
	falling:
		NBAL ABCD 2
		loop
	xdeath:
		TNT1 A 0
		TNT1 A 0 a_playsound ("daibatana/ballhit",0)
		FAXE RSTUVWX 1
		stop
	death:
		TNT1 A 0
		FAXE RSTUVWX 1
		stop
	}
		
}

actor spreadbatball
{
	projectile
	radius 10
	height 10
	speed 30
	damage 25
	+nobossrip
	+nodamagethrust
	Decal DoomImpScorch
	scale 0.50
	renderstyle add
	alpha 0.80
	states
	{
	spawn:
		NBAL ABCD 1
		loop
	death:
		TNT1 A 0
		TNT1 A 0 A_Playsound ("fuzzy/pdeath",0)
		FAXE RSTUVWX 2
		stop
	}
}

actor railball : spreadbatball
{
	speed 65
	damage 10
	states
	{
	spawn:	
		NBAL AB 1
		NBAL CD 1
		loop
	death:
		TNT1 A 0
		TNT1 A 0 A_Playsound ("fuzzy/pdeath",0)
		FAXE RSTUVWX 2
		stop
	}		
}

actor railballtrail
{
	+nointeraction
	+clientsideonly
	scale 0.50
	speed 55
	renderstyle add
	alpha 0.90
	states
	{
	spawn:
		NBAL ABCD 1
		TNT1 A 0
		stop
	}
}
	

actor ballrebound
{
	+notimefreeze
	+clientsideonly
	projectile
	+hexenbounce
	+ripper
	+bloodlessimpact
	bouncecount 5
	+FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+painless
	-nogravity
	gravity 1.5
	speed 40
	bouncefactor 0.80
	radius 2
	damage (0)
	scale 0.60
	seesound "daibatana/ballhitworld"
	states
	{
	spawn:
		NBAL ABCD 3 
		NBAL ABCD 3 
		NBAL ABCD 3 
		stop
	death:
		TNT1 A 0
		stop
	}
}


actor supermelee : fastprojectile
{
	Projectile
	speed 75
	damage 55
	+BLOODSPLATTER
	+thruspecies
	+dontblast
	+forceradiusdmg
	species "player"
	renderstyle add
	alpha 0.80
	height 15
	radius 8
	+noblood
    Decal BFGScorch
	scale 4.5
	mass 100000
	states
	{
	Spawn:
		TNT1 A 2
		stop
	Death:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("pipe/wall", CHAN_AUTO)
		TNT1 A 0 A_PlaySound("daibatana/supermiss", CHAN_AUTO)
		TNT1 A 0 A_SpawnDebris("WWStyleBulletSpark")
		TNT1 A 0 radius_quake (2,7,0,8,0)
		TNT1 A 5 
		stop
	Xdeath:
		TNT1 A 0
		TNT1 A 0 a_jump (80, "SMAAAASH")
		TNT1 A 0 A_PlaySound("daibatana/superhit", 0)
		TNT1 A 0 a_explode (120,150,0)
		TNT1 A 0 a_blast
		TNT1 A 0 A_radiusthrust (550000,60,0)
		TNT1 A 0 radius_quake (4,8,0,8,0)
		TNT1 AAAAAAAAAAAAAAAAAAAAAAA 0 a_spawnitemex ("MAXparticle",Frandom(-16,16),Frandom(-16,16),Frandom(-10,10),Frandom(-100,100)/20.0,Frandom(-100,100)/20.0,Frandom(-100,100)/20.0,0,160)
		PUF4 A 3 Bright 
		PUF4 B 2 Bright
		PUF4 C 2 Bright
		PUF4 D 1 Bright
		PUF4 E 1 Bright
		PUF4 F 1 Bright
		TNT1 A 5
		stop
	SMAAAASH:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("daibatana/crit", 0)
		TNT1 A 0 a_explode (280,250,0)
		TNT1 A 0 a_blast
		TNT1 A 0 A_radiusthrust (850000,80,0)
		TNT1 A 0 radius_quake (8,10,0,8,0)
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 a_spawnitemex ("MAXparticle",Frandom(-16,16),Frandom(-16,16),Frandom(-10,10),Frandom(-100,100)/20.0,Frandom(-100,100)/20.0,Frandom(-100,100)/20.0,0,160)
		TNT1 A 5
		EXPL ABCDEFGHIJKLMNOP 1
		stop
		
	}
}

actor MAXparticle
{
	projectile
	+clientsideonly
	speed 10
	+NOINTERACTION
	states
	{
	spawn:	
		PDBR AAAAAA 1  Bright A_SetTranslucent(.6,1)
		TNT1 AA 1  Bright 
		PDBR AA 1 Bright 
		TNT1 AA 1  Bright 
		PDBR A 1 Bright 
		TNT1 A 1  Bright 
		PDBR A 1 Bright 
		Stop
	}
}

actor batmelee : fastprojectile
{
	Projectile
	speed 74
	damage 10
	+BLOODSPLATTER
	+thruspecies
	+dontblast
	species "player"
	height 15
	radius 8
	+noblood
	mass 1000000
	states
	{
	Spawn:
		TNT1 A 2
		stop
	Death:
		TNT1 A 0
		TNT1 A 0
		TNT1 A 0 A_PlaySound("pipe/wall", CHAN_AUTO)
		TNT1 A 0 A_SpawnDebris("WWStyleBulletSpark")
		TNT1 A 0 radius_quake (2,7,0,8,0)
		TNT1 A 5 
		stop
	Xdeath:
		TNT1 A 0
		TNT1 A 0
		TNT1 A 0 A_PlaySound("daibatana/weakmelee", CHAN_AUTO)
		TNT1 A 0 radius_quake (2,7,0,8,0)
		TNT1 A 5
		stop
	}
}

//AMMO AND DUMMY ACTORS GO HERE

actor Batpower : ammo
{
  Inventory.PickupMessage "Bat power (you shouldn't find this either, quit summoning shit!)"
  Inventory.Amount 1
  Inventory.MaxAmount 4
  Inventory.Icon "BAL1A0"
  Ammo.BackpackAmount 0
  Ammo.BackpackMaxAmount 0
  states
  {
  Spawn:
    BAL1 A -1
    stop
  }
}

//Used to measure how much charge the player is building, at 300, they're given 100 batpower
//to use for power attacks

actor Batcharge : ammo
{
  Inventory.PickupMessage "Bat charge (you shouldn't find this either, you sneaky bastard)"
  Inventory.Amount 1
  Inventory.MaxAmount 300
  Inventory.Icon "BAL1A0"
  Ammo.BackpackAmount 0
  Ammo.BackpackMaxAmount 0
  states
  {
  Spawn:
    BAL1 A -1
    stop
  }
}