actor HakkeroBlaster : DoomWeapon
{
//$Category "Touhou Weapon Pack"
  Weapon.AmmoType "Cell"
  Weapon.AmmoUse 1
  Weapon.AmmoType2 "Cell"
  Weapon.AmmoUse2 1
  Weapon.AmmoGive 40
  Weapon.KickBack 75
  Weapon.SlotNumber 6
  Weapon.SlotPriority 0
  Inventory.PickupMessage "You got the Hakkero Blaster!"
  Tag "Hakkero Fire"
  +WEAPON.NOAUTOFIRE
  States
  {
  Ready:
    PLZM A 1 A_WeaponReady
    Loop
  Deselect:
    PLZM A 1 A_Lower
    Loop
  Select:
    PLZM A 1 A_Raise
    Loop
  Fire:
	PLZM B 0 BRIGHT A_FireCustomMissile("HakkeroShot",0,0,8,0,0,0)
	PLZM B 0 BRIGHT A_FireCustomMissile("HakkeroShot",0,0,-8,0,0,0)
	PLZM BBB 0 BRIGHT A_FireCustomMissile("HakkeroFire",frandom(-4,4),0,0,0,0,frandom(-2,2))
	PLZM B 1 BRIGHT A_FireCustomMissile("HakkeroFire",frandom(-4,4),1,0,0,0,frandom(-2,2))
	PLZM BBB 0 BRIGHT A_FireCustomMissile("HakkeroFire",frandom(-4,4),0,0,0,0,frandom(-2,2))
	PLZM B 1 BRIGHT A_FireCustomMissile("HakkeroFire",frandom(-4,4),0,0,0,0,frandom(-2,2))
	PLZM BBB 0 BRIGHT A_FireCustomMissile("HakkeroFire",frandom(-4,4),0,0,0,0,frandom(-2,2))
	PLZM B 1 BRIGHT A_FireCustomMissile("HakkeroFire",frandom(-4,4),1,0,0,0,frandom(-2,2))
	PLZM BBB 0 BRIGHT A_FireCustomMissile("HakkeroFire",frandom(-4,4),0,0,0,0,frandom(-2,2))
	PLZM B 1 BRIGHT A_FireCustomMissile("HakkeroFire",frandom(-4,4),0,0,0,0,frandom(-2,2))
	PLZM D 6 A_ReFire
    Goto Ready
  AltFire:
	PLZM A 0 A_PlaySound("hakkero/laser",CHAN_WEAPON,1.0,0,ATTN_IDLE)
	PLZM B 1 BRIGHT A_RailAttack(25, 0, 1, none, none, RGF_NOPIERCING|RGF_SILENT, 8192, "HakkeroLaserPuff", 0, 0, 0, 0, 8.0, 0, "HakkeroLaserTrail", 1)
	PLZM B 1 BRIGHT A_RailAttack(25, 0, 1, none, none, RGF_NOPIERCING|RGF_SILENT, 8192, "HakkeroLaserPuff", 0, 0, 0, 0, 8.0, 0, "HakkeroLaserTrail2", 1)
	PLZM B 1 BRIGHT A_RailAttack(25, 0, 1, none, none, RGF_SILENT, 8192, "HakkeroLaserPuff", 0, 0, 0, 0, 8.0, 0, "HakkeroLaserTrail3", 1)
	PLZM B 1 BRIGHT A_RailAttack(25, 0, 1, none, none, RGF_SILENT, 8192, "HakkeroLaserPuff", 0, 0, 0, 0, 8.0, 0, "HakkeroLaserTrail4", 1)
	PLZM B 1 BRIGHT A_FireCustomMissile("HakkeroShot",0,1,random(-16,16),0,0,0)
	PLZM B 1 BRIGHT A_FireCustomMissile("HakkeroShot2",0,0,random(-16,16),0,0,0)
	PLZM B 1 BRIGHT A_FireCustomMissile("HakkeroShot3",0,0,random(-16,16),0,0,0)
	PLZM B 1 BRIGHT A_FireCustomMissile("HakkeroShot4",0,0,random(-16,16),0,0,0)
	PLZM C 4 BRIGHT
	PLZM D 0 A_ReFire
    Goto Ready
  Spawn:
    PLZM E -1
    Stop
  }
}
ACTOR HakkeroLaserPuff : BulletPuff
{
  +FORCEXYBILLBOARD
  +BLOODLESSIMPACT
  DamageType "TouhouHakkeroLaser"
}
ACTOR HakkeroLaserTrail
{
  Radius 8
  Speed 10
  Height 12
  Scale 0.2
  Renderstyle Add
  Alpha 0.2
  +NOGRAVITY
  +NOINTERACTION
  +FORCEXYBILLBOARD
  States
  {
  Spawn:
    STA1 A 1 Bright A_FadeOut(0.02)
    Loop
  }
}
ACTOR HakkeroLaserTrail2 : HakkeroLaserTrail
{
  States
  {
  Spawn:
    STA3 A 1 Bright A_FadeOut(0.02)
    Loop
  }
}
ACTOR HakkeroLaserTrail3 : HakkeroLaserTrail
{
  States
  {
  Spawn:
    STA5 A 1 Bright A_FadeOut(0.02)
    Loop
  }
}
ACTOR HakkeroLaserTrail4 : HakkeroLaserTrail
{
  States
  {
  Spawn:
    STA7 A 1 Bright A_FadeOut(0.02)
    Loop
  }
}
ACTOR HakkeroFire
{
  Speed 38
  Radius 6
  Height 12
  damage (1)
  Scale 0.5
  Projectile
  Renderstyle Add
  +RIPPER
  +NOBOSSRIP
  +PAINLESS
  +BLOODLESSIMPACT
  +FORCERADIUSDMG
  +THRUSPECIES
  Species "Player"
  Alpha 0.25
  DeathSound ""
  DamageType "TouhouHakkeroFire"
  States
  {
/*
  Spawn:
	FIRE A 0
	Goto Death
  Death:
    FIRE A 0 Bright A_PlaySound("vile/firestrt",0,1.0,0)
    FIRE ABAB 1 Bright A_ScaleVelocity(0.96) //4
    FIRE C 0 Bright A_PlaySound("vile/firecrkl",0,1.0,0)
    FIRE CBCBCDCDCDEDED 1 Bright A_ScaleVelocity(0.96) //18
    FIRE E 0 Bright A_PlaySound("vile/firecrkl",0,1.0,0)
    FIRE EFEFEFGHGHGH 1 Bright A_ScaleVelocity(0.96) //30
    Stop
*/
  Spawn:
	TNT1 A 0 Bright
    TNT1 A 0 Bright A_PlaySound("vile/firestrt",0,1.0,0)
    TNT1 A 7 Bright A_SetTics(random(1,13))
    TNT1 A 0 Bright A_ScaleVelocity(0.75)
    TNT1 A 0 Bright A_PlaySound("vile/firecrkl",0,1.0,0)
    TNT1 A 0 Bright A_SpawnItemEx("TouhouFireSFX", 0, 0)
    TNT1 A 7 Bright A_SetTics(random(1,13))
    TNT1 A 0 Bright A_ScaleVelocity(0.75)
    TNT1 A 0 Bright A_SpawnItemEx("TouhouFireSFX", 0, 0)
    TNT1 A 7 Bright A_SetTics(random(1,13))
    TNT1 A 0 Bright A_ScaleVelocity(0.75)
    TNT1 A 0 Bright A_SpawnItemEx("TouhouFireSFX", 0, 0)
    TNT1 A 7 Bright A_SetTics(random(1,13))
    TNT1 A 0 Bright A_ScaleVelocity(0.75)
    TNT1 A 0 Bright A_SpawnItemEx("TouhouFireSFX", 0, 0)
    TNT1 A 7 Bright A_SetTics(random(1,13))
    TNT1 A 0 Bright A_ScaleVelocity(0.75)
    TNT1 A 0 Bright A_SpawnItemEx("TouhouFireSFX", 0, 0)
	Stop
  Death:
	TNT1 A 0 A_Explode(3,16,0)
    TNT1 A 0 Bright A_PlaySound("vile/firecrkl",0,1.0,0)
    TNT1 A 0 Bright A_SpawnItemEx("TouhouFireSFX", 0, 0)
    Stop
  }
}

ACTOR TouhouFire
{
  Speed 5
  +CLIENTSIDEONLY
  +NOBLOCKMAP
  +NOCLIP
  +NOGRAVITY
  +NOSECTOR
  +NOINTERACTION
  +DONTSPLASH
  States
  {
  Spawn:
    TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_SpawnItemEx("TouhouFireSFX", 1, 4)
    Stop
  }
}

ACTOR TouhouFireSFX
{
  +CLIENTSIDEONLY
  +NOCLIP
  +NOBLOCKMAP
  +NOGRAVITY
  +NOSECTOR
  +NOINTERACTION
  +DONTSPLASH
  Obituary "How did you die to entirely clientsided SFX?!"
  States
  {
  Spawn:
    TNT1 A 0 A_SpawnItemEx("SmallFlame", 0, 0, 0, 0, 0, 0, 0, 128)
    TNT1 A 0 A_Jump(216, 2)
    TNT1 A 1 A_SpawnItemEx("Flame1A", 0, 0, 0, 0, 0, 0, 0, 128)
    Goto death
    TNT1 A 0 A_Jump(176, 2)
    TNT1 A 1 A_SpawnItemEx("Flame1B", 0, 0, 0, 0, 0, 0, 0, 128)
    Goto death
    TNT1 A 0 A_Jump(136, 2)
    TNT1 A 1 A_SpawnItemEx("Flame2A", 0, 0, 0, 0, 0, 0, 0, 128)
    Goto death
    TNT1 A 0 A_Jump(96, 2)
    TNT1 A 1 A_SpawnItemEx("Flame2B", 0, 0, 0, 0, 0, 0, 0, 128)
    Goto death
    TNT1 A 0 A_Jump(56, 2)
    TNT1 A 1 A_SpawnItemEx("Flame3A", 0, 0, 0, 0, 0, 0, 0, 128)
    Goto death
    TNT1 A 1 A_SpawnItemEx("Flame3B", 0, 0, 0, 0, 0, 0, 0, 128)
    Goto death
  Death:
    TNT1 A 1
    Stop
  }
}

//Dynamic Light actors
Actor SmallFlame
{
  +ClientSideOnly
  +NoClip
  +NoBlockMap
  +NoGravity
  +NoInteraction
  States
  {
  Spawn:
   TNT1 A 1
   Stop
  }
}
//Flames and particles

Actor Flame1A
{
  Height 2
  Radius 1
  +NoGravity
  +NoBlockMap
  +Missile
  +NoInteraction
  +ForceXYBillboard
  +ClientSideOnly
  RenderStyle Add
  Alpha 0.8
  Scale 0.35
  States
  {
  Spawn:
    FLM1 A 0
    FLM1 A 0 ThrustThingZ(0, Random(2, 6), 0, 0)
    FLM1 A 0 ThrustThing(Random(0, 255), Random(0, 1), 0, 0)
    FLM1 ABCDE 2 Bright
    FLM1 F 1 Bright A_SetTranslucent(0.75, 1)
    FLM1 F 1 Bright A_SetTranslucent(0.7, 1)
    FLM1 G 1 Bright A_SetTranslucent(0.65, 1)
    FLM1 G 1 Bright A_SetTranslucent(0.6, 1)
    FLM1 H 1 Bright A_SetTranslucent(0.55, 1)
    FLM1 H 1 Bright A_SetTranslucent(0.5, 1)
    FLM1 I 1 Bright A_SetTranslucent(0.45, 1)
    FLM1 I 1 Bright A_SetTranslucent(0.4, 1)
    FLM1 J 1 Bright A_SetTranslucent(0.35, 1)
    FLM1 J 1 Bright A_SetTranslucent(0.3, 1)
    FLM1 K 1 Bright A_SetTranslucent(0.25, 1)
    FLM1 K 1 Bright A_SetTranslucent(0.2, 1)
    FLM1 L 1 Bright A_SetTranslucent(0.15, 1)
    FLM1 L 1 Bright A_SetTranslucent(0.1, 1)
    Stop
  }
}

Actor Flame1B : Flame1A
{
  States
  {
  Spawn:
    FLM2 A 0
    FLM2 A 0 ThrustThingZ(0, Random(2, 6), 0, 0)
    FLM2 A 0 ThrustThing(Random(0, 255), Random(0, 1), 0, 0)
    FLM2 ABCDE 2 Bright
    FLM2 F 1 Bright A_SetTranslucent(0.75, 1)
    FLM2 F 1 Bright A_SetTranslucent(0.7, 1)
    FLM2 G 1 Bright A_SetTranslucent(0.65, 1)
    FLM2 G 1 Bright A_SetTranslucent(0.6, 1)
    FLM2 H 1 Bright A_SetTranslucent(0.55, 1)
    FLM2 H 1 Bright A_SetTranslucent(0.5, 1)
    FLM2 I 1 Bright A_SetTranslucent(0.45, 1)
    FLM2 I 1 Bright A_SetTranslucent(0.4, 1)
    FLM2 J 1 Bright A_SetTranslucent(0.35, 1)
    FLM2 J 1 Bright A_SetTranslucent(0.3, 1)
    FLM2 K 1 Bright A_SetTranslucent(0.25, 1)
    FLM2 K 1 Bright A_SetTranslucent(0.2, 1)
    FLM2 L 1 Bright A_SetTranslucent(0.15, 1)
    FLM2 L 1 Bright A_SetTranslucent(0.1, 1)
    Stop
  }
}

Actor Flame2A : Flame1A
{
  States
  {
  Spawn:
    FLM3 A 0
    FLM3 A 0 ThrustThingZ(0, Random(2, 6), 0, 0)
    FLM3 A 0 ThrustThing(Random(0, 255), Random(0, 1), 0, 0)
    FLM3 ABCDE 2 Bright
    FLM3 F 1 Bright A_SetTranslucent(0.75, 1)
    FLM3 F 1 Bright A_SetTranslucent(0.7, 1)
    FLM3 G 1 Bright A_SetTranslucent(0.65, 1)
    FLM3 G 1 Bright A_SetTranslucent(0.6, 1)
    FLM3 H 1 Bright A_SetTranslucent(0.55, 1)
    FLM3 H 1 Bright A_SetTranslucent(0.5, 1)
    FLM3 I 1 Bright A_SetTranslucent(0.45, 1)
    FLM3 I 1 Bright A_SetTranslucent(0.4, 1)
    FLM3 J 1 Bright A_SetTranslucent(0.35, 1)
    FLM3 J 1 Bright A_SetTranslucent(0.3, 1)
    FLM3 K 1 Bright A_SetTranslucent(0.25, 1)
    FLM3 K 1 Bright A_SetTranslucent(0.2, 1)
    FLM3 L 1 Bright A_SetTranslucent(0.15, 1)
    FLM3 L 1 Bright A_SetTranslucent(0.1, 1)
    Stop
  }
}

Actor Flame2B : Flame1A
{
  States
  {
  Spawn:
    FLM4 A 0
    FLM4 A 0 ThrustThingZ(0, Random(2, 6), 0, 0)
    FLM4 A 0 ThrustThing(Random(0, 255), Random(0, 1), 0, 0)
    FLM4 ABCDE 2 Bright
    FLM4 F 1 Bright A_SetTranslucent(0.75, 1)
    FLM4 F 1 Bright A_SetTranslucent(0.7, 1)
    FLM4 G 1 Bright A_SetTranslucent(0.65, 1)
    FLM4 G 1 Bright A_SetTranslucent(0.6, 1)
    FLM4 H 1 Bright A_SetTranslucent(0.55, 1)
    FLM4 H 1 Bright A_SetTranslucent(0.5, 1)
    FLM4 I 1 Bright A_SetTranslucent(0.45, 1)
    FLM4 I 1 Bright A_SetTranslucent(0.4, 1)
    FLM4 J 1 Bright A_SetTranslucent(0.35, 1)
    FLM4 J 1 Bright A_SetTranslucent(0.3, 1)
    FLM4 K 1 Bright A_SetTranslucent(0.25, 1)
    FLM4 K 1 Bright A_SetTranslucent(0.2, 1)
    FLM4 L 1 Bright A_SetTranslucent(0.15, 1)
    FLM4 L 1 Bright A_SetTranslucent(0.1, 1)
    Stop
  }
}

Actor Flame3A : Flame1A
{
  States
  {
  Spawn:
    FLM5 A 0
    FLM5 A 0 ThrustThingZ(0, Random(2, 6), 0, 0)
    FLM5 A 0 ThrustThing(Random(0, 255), Random(0, 1), 0, 0)
    FLM5 ABCDE 2 Bright
    FLM5 F 1 Bright A_SetTranslucent(0.75, 1)
    FLM5 F 1 Bright A_SetTranslucent(0.7, 1)
    FLM5 G 1 Bright A_SetTranslucent(0.65, 1)
    FLM5 G 1 Bright A_SetTranslucent(0.6, 1)
    FLM5 H 1 Bright A_SetTranslucent(0.55, 1)
    FLM5 H 1 Bright A_SetTranslucent(0.5, 1)
    FLM5 I 1 Bright A_SetTranslucent(0.45, 1)
    FLM5 I 1 Bright A_SetTranslucent(0.4, 1)
    FLM5 J 1 Bright A_SetTranslucent(0.35, 1)
    FLM5 J 1 Bright A_SetTranslucent(0.3, 1)
    FLM5 K 1 Bright A_SetTranslucent(0.25, 1)
    FLM5 K 1 Bright A_SetTranslucent(0.2, 1)
    FLM5 L 1 Bright A_SetTranslucent(0.15, 1)
    FLM5 L 1 Bright A_SetTranslucent(0.1, 1)
    Stop
  }
}

Actor Flame3B : Flame1A
{
  States
  {
  Spawn:
    FLM6 A 0
    FLM6 A 0 ThrustThingZ(0, Random(2, 6), 0, 0)
    FLM6 A 0 ThrustThing(Random(0, 255), Random(0, 1), 0, 0)
    FLM6 ABCDE 2 Bright
    FLM6 F 1 Bright A_SetTranslucent(0.75, 1)
    FLM6 F 1 Bright A_SetTranslucent(0.7, 1)
    FLM6 G 1 Bright A_SetTranslucent(0.65, 1)
    FLM6 G 1 Bright A_SetTranslucent(0.6, 1)
    FLM6 H 1 Bright A_SetTranslucent(0.55, 1)
    FLM6 H 1 Bright A_SetTranslucent(0.5, 1)
    FLM6 I 1 Bright A_SetTranslucent(0.45, 1)
    FLM6 I 1 Bright A_SetTranslucent(0.4, 1)
    FLM6 J 1 Bright A_SetTranslucent(0.35, 1)
    FLM6 J 1 Bright A_SetTranslucent(0.3, 1)
    FLM6 K 1 Bright A_SetTranslucent(0.25, 1)
    FLM6 K 1 Bright A_SetTranslucent(0.2, 1)
    FLM6 L 1 Bright A_SetTranslucent(0.15, 1)
    FLM6 L 1 Bright A_SetTranslucent(0.1, 1)
    Stop
  }
}