actor AlienSpeed : PowerSpeed
{
 Powerup.Duration -0x7FFFFFFF
 speed 0.5
}

actor SmartGun : AliensWeapon replaces PlasmaRifle
{
 Inventory.Pickupmessage "You aquired an M56 smart gun, thankfully with a harness!"
 weapon.selectionorder 900
 weapon.kickback 100
 tag "M56 Smartgun"
 weapon.ammotype "HeavyMag"
 weapon.ammouse 0
 weapon.ammogive 200
 weapon.slotnumber 6
 scale 0.7
 +weapon.noalert
 +weapon.noautofire
 states
 {
  Spawn:
    SGUN H -1
    loop
  AltReady:
	SLWR E 1 A_WeaponReady
	loop
  Ready:
	TNT1 A 0 A_TakeInventory("PauseForThought", 1)
    TNT1 A 0 A_JumpIfInventory("KickItem", 1, "PreKick")
	TNT1 A 0 A_JumpIfInventory("TrackerToggle", 1, "PreTrack")
    SGUN B 1 A_WeaponReady
    loop
  Select:
    SGUN B 1 A_Raise
    loop
  Deselect:
	TNT1 A 0 A_TakeInventory("AltReady", 1)
	TNT1 A 0 A_TakeInventory("AlienSpeed", 1)
	TNT1 A 0 A_TakeInventory("PauseForThought", 1)
    SGUN B 1 A_Lower
    loop
  Fire:
	TNT1 A 0 A_JumpIfInventory("AltReady", 1, "RealFire")
	TNT1 A 0 A_JumpIfInventory("PauseForThought", 1, "RealFire")
	TNT1 A 0 A_JumpIfInventory("RadarActive", 1, "TrackerLower")
    SLWR B 1
    SLWR C 2
    SLWR D 2
	SLWR E 3
  RealFire:
	SGUN B 0 A_JumpIfInventory("HeavyMag",1,1)
	goto FireLower
	SLWR E 1
    TNT1 A 0 A_PlayWeaponSound("weapons/smartgun")
    TNT1 A 0 A_AlertMonsters
    TNT1 A 0 Radius_Quake(4,2,0,1,0)
    TNT1 A 0 A_Recoil(0.2)
	TNT1 A 0 A_TakeInventory("HeavyMag", 1)
  FlashJump:
    TNT1 A 0 A_Jump(256, "Flash1", "Flash2", "Flash3", "Flash4", "Flash5")
  Flash1:
	TNT1 A 0 A_FireCustomMissile("GunSpark",1.5+random(-5.5,5.5),0,0,6,0,1.5+random(-2.8,2.8))
	TNT1 A 0 A_FireCustomMissile("GunSpark2",1.5+random(-5.5,5.5),0,0,6,0,1.5+random(-2.8,2.8))
    SGUN C 1 BRIGHT A_FireCustomMissile("SmartTracer", Frandom(-3,3), 1, 0, 0, 0, Frandom(-2,2))
	TNT1 A 0 A_FireBullets(0, 0, 1, 0, "InvisiPuff")
    goto fireend
  Flash2:
	TNT1 A 0 A_FireCustomMissile("GunSpark",1.5+random(-5.5,5.5),0,0,6,0,1.5+random(-2.8,2.8))
	TNT1 A 0 A_FireCustomMissile("GunSpark2",1.5+random(-5.5,5.5),0,0,6,0,1.5+random(-2.8,2.8))
    SGUN D 1 BRIGHT A_FireCustomMissile("SmartTracer", Frandom(-3,3), 1, 0, 0, 0, Frandom(-2,2))
	TNT1 A 0 A_FireBullets(0, 0, 1, 0, "InvisiPuff")
    goto fireend
  Flash3:
	TNT1 A 0 A_FireCustomMissile("GunSpark",1.5+random(-5.5,5.5),0,0,6,0,1.5+random(-2.8,2.8))
	TNT1 A 0 A_FireCustomMissile("GunSpark2",1.5+random(-5.5,5.5),0,0,6,0,1.5+random(-2.8,2.8))
    SGUN E 1 BRIGHT A_FireCustomMissile("SmartTracer", Frandom(-3,3), 1, 0, 0, 0, Frandom(-2,2))
	TNT1 A 0 A_FireBullets(0, 0, 1, 0, "InvisiPuff")
    goto fireend
  Flash4:
	TNT1 A 0 A_FireCustomMissile("GunSpark",1.5+random(-5.5,5.5),0,0,6,0,1.5+random(-2.8,2.8))
	TNT1 A 0 A_FireCustomMissile("GunSpark2",1.5+random(-5.5,5.5),0,0,6,0,1.5+random(-2.8,2.8))
    SGUN F 1 BRIGHT A_FireCustomMissile("SmartTracer", Frandom(-3,3), 1, 0, 0, 0, Frandom(-2,2))
	TNT1 A 0 A_FireBullets(0, 0, 1, 0, "InvisiPuff")
    goto fireend
  Flash5:
	TNT1 A 0 A_FireCustomMissile("GunSpark",1.5+random(-5.5,5.5),0,0,6,0,1.5+random(-2.8,2.8))
	TNT1 A 0 A_FireCustomMissile("GunSpark2",1.5+random(-5.5,5.5),0,0,6,0,1.5+random(-2.8,2.8))
    SGUN G 1 BRIGHT A_FireCustomMissile("SmartTracer", Frandom(-3,3), 1, 0, 0, 0, Frandom(-2,2))
	TNT1 A 0 A_FireBullets(0, 0, 1, 0, "InvisiPuff")
  FireEnd:
    TNT1 A 0 Radius_Quake(4,2,0,1,0)
    TNT1 A 0 A_SetPitch (pitch-0.6)
    SLWR E 3 A_Refire("RealFire")
	SLWR E 1 A_StopSound(CHAN_WEAPON)
	SLWR E 1 A_PlaySound ("weapons/pulseend", CHAN_WEAPON)
	TNT1 A 0 A_GiveInventory("PauseForThought", 1)
	TNT1 A 0 A_JumpIfInventory("AltReady", 1, "AltReady")
	SLWR EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 1 A_WeaponReady
  FireLower:
	TNT1 A 0 A_TakeInventory("PauseForThought", 1)
	SLWR E 1 A_StopSound(CHAN_WEAPON)
    TNT1 A 0 A_SetPitch (pitch-0.4)
    SLWR D 2
    TNT1 A 0 A_SetPitch (pitch-0.2)
    SLWR C 2
    TNT1 A 0 A_SetPitch (pitch+0.1)
    SLWR B 1
    TNT1 A 0 A_SetPitch (pitch+0.1)
    goto ready
  AltFire:
	TNT1 A 0 A_JumpIfInventory("AltReady", 1, "TakeReady")
	TNT1 A 0 A_GiveInventory("AltReady")
	TNT1 A 0 A_GiveInventory("AlienSpeed", 1)
	SLWR B 1
    SLWR C 2
    SLWR D 2
	SLWR E 3
	goto AltReady
  TakeReady:
	TNT1 A 0 A_TakeInventory("AltReady", 1)
	TNT1 A 0 A_TakeInventory("AlienSpeed", 1)
	goto FireLower
  PreKick:
	SGUN B 1 offset(-8, 40)
	SGUN B 1 offset(-24, 56)
	SGUN B 1 offset(-40, 72)
	SGUN B 1 offset(-50, 88)
	SGUN B 1 offset(-66, 104)
	goto Kick
  PostKick:
	SGUN B 1 offset(-66, 104)
	SGUN B 1 offset(-50, 88)
	SGUN B 1 offset(-40, 72)
	SGUN B 1 offset(-24, 56)
	SGUN B 1 offset(-8, 40)
	goto ready
 PreTrack:
	SGUN B 1 offset(-8, 40)
	SGUN B 1 offset(-24, 56)
	SGUN B 1 offset(-40, 72)
	SGUN B 1 offset(-50, 88)
	SGUN B 1 offset(-66, 104)
	goto TrackRaise
  PostTrack:
	SGUN B 1 offset(-66, 104)
    SGUN B 1 offset(-50, 88)
	SGUN B 1 offset(-40, 72)
	SGUN B 1 offset(-24, 56)
	SGUN B 1 offset(-8, 40)
	goto ready
  }
}