// Pulse Rifle

ACTOR PulseRifle : IDMWeapon
{
  Inventory.PickupMessage "Pulse Rifle! (Slot 6)"
  Weapon.AmmoType "IDMCell"
  Weapon.AmmoUse 3
  Weapon.AmmoGive 40
  Weapon.Selectionorder 100
  //Weapon.PreferredSkin "PulseMarine"
  Decal "ArachnotronScorch"
  Tag "Pulse Rifle"
  +WEAPON.NOLMS
  States
  {
  Spawn:
    PULS A -1 Bright
    stop
  Ready:
      PULS B 1 A_WeaponReady
      Loop
  Deselect:
      PULS B 0 A_Lower
      PULS B 0 A_Lower
      PULS B 1 A_Lower
      Loop
  Select:
	TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
  Sloop:
      PULS B 0 A_Raise
      PULS B 0 A_Raise
      PULS B 1 A_Raise
      loop
  Fire:
      PULS C 1 Bright
	  PULS D 0 A_GunFlash
	  PULS D 0 A_JumpIfInventory("PowerIDMWeaponLevel2",1,"Level2")
	  PULS D 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
  Normal:
      PULS D 2 Bright A_FireCustomMissile("PulseBall",0,1)
	  Goto FireEnd
  Level2:
	  PULS D 0 A_JumpIfInventory("PowerQuadDamage",1,"QuadLevel2")
      PULS D 0 Bright A_FireCustomMissile("PulseBall2",random(-4,4),1)
      PULS D 0 Bright A_FireCustomMissile("PulseBall2",random(-4,4),0)
      PULS D 2 Bright A_FireCustomMissile("PulseBall2",random(-4,4),0)
	  Goto FireEnd
  Quad:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5,1)
      PULS D 2 Bright A_FireCustomMissile("ExtremePulseBall",0,1)
	  Goto FireEnd
  QuadLevel2:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5,1)
      PULS D 0 Bright A_FireCustomMissile("ExtremePulseBall2",random(-4,4),1)
      PULS D 0 Bright A_FireCustomMissile("ExtremePulseBall2",random(-4,4),0)
      PULS D 2 Bright A_FireCustomMissile("ExtremePulseBall2",random(-4,4),0)
  FireEnd:
	  PULS C 2 Bright
      PULS B 1
	  PULS B 2 A_ReFire
      Goto Ready
  Flash:
	  NULL A 7 A_Light1
	  Goto LightDone
  }
}

// Pulse Rifle's Plasma

ACTOR PulseBall : FastProjectile
{
	Radius 13
	Height 8
	Projectile
	ProjectileKickBack 100
	Speed 40
	Damage (40 * random(1,4))
	RenderStyle Translucent
	+RANDOMIZE
	-NOTELEPORT
	+SKYEXPLODE
	Alpha 1
	Obituary "%o was scorched by %k's Pulse Rifle."
	SelfObituary "%o scorched %hself with pulse splash damage."
	Seesound "weapons/plsrf"
	DeathSound "weapons/pulsex"
	DamageType "Pulse"
	Decal Arachnotronscorch
	States
	{
	Spawn:
		APLS AB 2 Bright
		TNT1 A 0 A_Jump(128,"SpawnLoop2")
	SpawnLoop:
		APLS BBAA 1 Bright A_Weave(frandom(10,30),0,frandom(0,6),0)
		Loop
	SpawnLoop2:
		APLS BBAA 1 Bright A_Weave(frandom(10,30),0,frandom(-6,0),0)
		Loop
	Death:
		APBX A 0 A_Explode(random(1,10),64,1,1,64)
		APBX A 4 Bright
		APBX BCDE 3 Bright
		Stop
	}
}

ACTOR ExtremePulseBall : PulseBall
{
	+EXTREMEDEATH
	States
	{
	XDeath:
		TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
		Goto Death
	}
}

ACTOR PulseBall2 : PulseBall
{
	Seesound "weapons/plsrf2"
	States
	{
	XDeath:
	  TNT1 AAA 0 A_CustomMissile("PulseBall2",0,0,random(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-5,5))
	  Goto Death
	}
}

ACTOR ExtremePulseBall2 : Pulseball2
{
	+EXTREMEDEATH
	States
	{
	XDeath:
	  TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
	  TNT1 AAA 0 A_CustomMissile("ExtremePulseBall2",0,0,random(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-5,5))
	  Goto Death
	}
}