ACTOR BulletPuffsmart
{
  Game Doom
  +NOBLOCKMAP
  +NOGRAVITY
  +ALLOWPARTICLES
  +RANDOMIZE
  RenderStyle Translucent
  Alpha 0.5
  VSpeed 1
  Mass 5
  States
  {
  Spawn:
    TNTT A 4 Bright
    TNTT B 4
    // Intentional fall-through
  Melee:
    TNTT CD 4
    Stop
  }
}

actor Smartgun : Weapon
{
  Game Doom
  Weapon.SelectionOrder 1500
  weapon.ammotype "Heat"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammogive2 100
  weapon.ammotype2 "Heatlimt"
  Obituary "$OB_MPPISTOL" // "%o was tickled by %k's pea shooter."
  Inventory.Pickupmessage "$PICKUP_PISTOL_DROPPED" // "Picked up a pistol."
 +AMMO_OPTIONAL
  States
  {
  Ready:
	SMRT A 0 A_JumpIfInventory("thrownade",1,"ThrowGrenade")
	SMRT A 0 A_JumpIfInventory("Kinfeammo",1,"UseKnife")  
    SMRT A 1 A_WeaponReady
    loop  
  Deselect: 
    SMRT A 0 A_Lower
    SMRT A 0 A_Lower
    SMRT A 1 A_Lower
    loop
  Select:
    SMRT A 0 A_Raise
    SMRT A 0 A_Raise
    SMRT A 1 A_Raise
    loop
   Fire: 
      SMRT B 0 Bright A_GunFlash
      SMRT G 0 A_JumpIfInventory ("Heat",100,"overheated")      
      SMRT A 0 A_playweaponsound ("smrtfire")      
      SMRT B 1 Bright A_FireBullets (0, 0, 1, Random(215,215), "BulletPuff",0)
      SMRT G 0 A_GiveInventory ("Heat", 2)
      SMRT C 1 Bright A_FireBullets (0, 0, 1, Random(215,215), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("Heat",100,"overheated")     
      SMRT G 0 A_GiveInventory ("Heat", 2)    
      SMRT B 1 Bright A_FireBullets (0, 0, 1, Random(215,215), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("Heat",100,"overheated")
      SMRT G 0 A_GiveInventory ("Heat", 2)
      SMRT C 1 Bright A_FireBullets (0, 0, 1, Random(215,215), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("Heat",100,"overheated")
      SMRT G 0 A_GiveInventory ("Heat", 2)      
      SMRT B 1 Bright A_FireBullets (0, 0, 1, Random(215,215), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("Heat",100,"overheated")
      SMRT G 0 A_GiveInventory ("Heat", 2)
      SMRT C 1 Bright A_FireBullets (0, 0, 1, Random(215,215), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("Heat",100,"overheated")     
      SMRT G 0 A_GiveInventory ("Heat", 2)    
      SMRT B 1 Bright A_FireBullets (0, 0, 1, Random(215,215), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("Heat",100,"overheated")
      SMRT G 0 A_GiveInventory ("Heat", 2)
      SMRT C 1 Bright A_FireBullets (0, 0, 1, Random(215,215), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("Heat",100,"overheated")     
      SMRT G 0 A_GiveInventory ("Heat", 2)                            
      SMRT G 0 A_JumpIfInventory ("Heat",100,"overheated")
      SMRT H 0 Bright A_GunFlash
      SMRT H 0 A_ReFire      
      SMRT DDDD 2 A_TakeInventory ("Heat",8)
      SMRT EEEE 2 A_TakeInventory ("Heat",8)
      SMRT FFFF 2 A_TakeInventory ("Heat",100)
      Goto ready
   Overheated:
    SMRT A 0      
      SMRT D 0 A_playsound("pulsrout")
      SMRT D 0 A_TakeInventory ("Heat",7)
      SMRT D 3 A_TakeInventory ("Heat",7)
      SMRT D 3 A_TakeInventory ("Heat",7)
      SMRT E 3 A_TakeInventory ("Heat",7)
      SMRT E 3 A_TakeInventory ("Heat",7)
      SMRT E 3 A_TakeInventory ("Heat",7)
      SMRT E 3 A_TakeInventory ("Heat",7)
      SMRT E 3 A_TakeInventory ("Heat",7)
      SMRT E 3 A_TakeInventory ("Heat",7)
      SMRT E 3 A_TakeInventory ("Heat",7)
      SMRT E 3 A_TakeInventory ("Heat",7)
      SMRT E 3 A_TakeInventory ("Heat",7)
      SMRT E 3 A_TakeInventory ("Heat", 7)
      SMRT E 3 A_TakeInventory ("Heat", 7)
      SMRT E 3 A_TakeInventory ("Heat", 7)
      SMRT E 4
      SMRT E 6
      SMRT F 9
      SMRT A 10
      SMRT A 12
      Goto Ready       
   Flash:
      NULL A 1 A_Light2
      NULL A 1 A_Light1
      NULL A 0 A_Light0
      stop
  ThrowGrenade:
     HNDG BCD 1
     HNDG E 1 A_PlaySound("weapons/grenadepin")
     HNDG FGHH 1
     HNDG I 1 A_PlaySound("weapons/grenadethr") 
     HNDG J 0 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
     HNDG J 0 A_PlaySound("weapons/grenadethr")
     HNDG JKLMNOPQ 1
     HNDG Q 0 A_TakeInventory("thrownade")
     Goto Ready
  Useknife:
     KNFG A 0 A_jumpifinventory("Machete",1,"UseMachete")
     KNFG ABC 2
	 KNFG C 0 A_CustomPunch (110,1,0,"KnifePuff")
	 KNFG DEF 2
	 KNFG F 0 A_TakeInventory("Kinfeammo")
	 goto ready
  UseMachete:
     MHT4 ABC 2
	 MHT4 C 0 A_CustomPunch (450,1,0,"Machetepuff")
	 MHT4 DEFG 2
	 MHT4 G 0 A_TakeInventory("Kinfeammo")
	 goto ready
  Spawn:
    GEWE Z -1
	stop
  }
}

actor Heat : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 100
    ammo.backpackamount 0
    ammo.backpackmaxamount 100
    +IGNORESKILL
}

actor Heatlimt : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 100
    inventory.maxamount 100
    ammo.backpackamount 100
    ammo.backpackmaxamount 100
    +IGNORESKILL
}

actor Hal's_Smartgun : Weapon
{
  Game Doom
  Weapon.SelectionOrder 1500
  weapon.ammotype "PAPHeat"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammogive2 200
  weapon.ammotype2 "PAPHeatlimt"
  Obituary "$OB_MPPISTOL" // "%o was tickled by %k's pea shooter."
  Inventory.Pickupmessage "$PICKUP_PISTOL_DROPPED" // "Picked up a pistol."
 +AMMO_OPTIONAL
  States
  {
  Ready:
	SMRT A 0 A_JumpIfInventory("thrownade",1,"ThrowGrenade")
	SMRT A 0 A_JumpIfInventory("Kinfeammo",1,"UseKnife")  
    SMRT A 1 A_WeaponReady
    loop  
  Deselect: 
    SMRT A 0 A_Lower
    SMRT A 0 A_Lower
    SMRT A 1 A_Lower
    loop
  Select:
    SMRT A 0 A_Raise
    SMRT A 0 A_Raise
    SMRT A 1 A_Raise
    loop
   Fire: 
      SMRT B 0 Bright A_GunFlash
      SMRT G 0 A_JumpIfInventory ("PAPHeat",200,"overheated")      
      SMRT A 0 A_playweaponsound ("smrtfire")      
      SMRT B 1 Bright A_FireBullets (0, 0, 1, Random(315,315), "BulletPuff",0)
      SMRT G 0 A_GiveInventory ("PAPHeat", 2)
      SMRT C 1 Bright A_FireBullets (0, 0, 1, Random(315,315), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("PAPHeat",200,"overheated")     
      SMRT G 0 A_GiveInventory ("PAPHeat", 2)    
      SMRT B 1 Bright A_FireBullets (0, 0, 1, Random(315,315), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("PAPHeat",200,"overheated")
      SMRT G 0 A_GiveInventory ("PAPHeat", 2)
      SMRT C 1 Bright A_FireBullets (0, 0, 1, Random(315,315), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("PAPHeat",200,"overheated")
      SMRT G 0 A_GiveInventory ("PAPHeat", 2)      
      SMRT B 1 Bright A_FireBullets (0, 0, 1, Random(315,315), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("PAPHeat",200,"overheated")
      SMRT G 0 A_GiveInventory ("PAPHeat", 2)
      SMRT C 1 Bright A_FireBullets (0, 0, 1, Random(315,315), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("PAPHeat",200,"overheated")     
      SMRT G 0 A_GiveInventory ("PAPHeat", 2)    
      SMRT B 1 Bright A_FireBullets (0, 0, 1, Random(315,315), "BulletPuff",0)
      SMRT A 1 A_JumpIfInventory ("PAPHeat",200,"overheated")
      SMRT G 0 A_GiveInventory ("PAPHeat", 2)
      SMRT C 1 Bright A_FireBullets (0, 0, 1, Random(315,315), "BulletPuff",0) 
      SMRT A 1 A_JumpIfInventory ("PAPHeat",200,"overheated")     
      SMRT G 0 A_GiveInventory ("PAPHeat", 2)                            
      SMRT G 0 A_JumpIfInventory ("PAPHeat",200,"overheated")
      SMRT H 0 Bright A_GunFlash
      SMRT H 0 A_ReFire      
      SMRT DDDD 2 A_TakeInventory ("PAPHeat",8)
      SMRT EEEE 2 A_TakeInventory ("PAPHeat",8)
      SMRT FFFF 2 A_TakeInventory ("PAPHeat",200)
      Goto ready
   Overheated:
    SMRT A 0     
      SMRT D 0 A_playsound("pulsrout")
      SMRT D 0 A_TakeInventory ("PAPHeat",17)
      SMRT D 3 A_TakeInventory ("PAPHeat",17)
      SMRT D 3 A_TakeInventory ("PAPHeat",17)
      SMRT E 3 A_TakeInventory ("PAPHeat",17)
      SMRT E 3 A_TakeInventory ("PAPHeat",17)
      SMRT E 3 A_TakeInventory ("PAPHeat",17)
      SMRT E 3 A_TakeInventory ("PAPHeat",17)
      SMRT E 3 A_TakeInventory ("PAPHeat",17)
      SMRT E 3 A_TakeInventory ("PAPHeat",17)
      SMRT E 3 A_TakeInventory ("PAPHeat",17)
      SMRT E 3 A_TakeInventory ("PAPHeat",17)
      SMRT E 3 A_TakeInventory ("PAPHeat",17)
      SMRT E 3 A_TakeInventory ("PAPHeat", 17)
      SMRT E 3 A_TakeInventory ("PAPHeat", 17)
      SMRT E 3 A_TakeInventory ("PAPHeat", 17)
      SMRT E 4
      SMRT E 6
      SMRT F 9
      SMRT A 10
      SMRT A 12
      Goto Ready       
   Flash:
      NULL A 1 A_Light2
      NULL A 1 A_Light1
      NULL A 0 A_Light0
      stop
  ThrowGrenade:
     HNDG BCD 1
     HNDG E 1 A_PlaySound("weapons/grenadepin")
     HNDG FGHH 1
     HNDG I 1 A_PlaySound("weapons/grenadethr") 
     HNDG J 0 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
     HNDG J 0 A_PlaySound("weapons/grenadethr")
     HNDG JKLMNOPQ 1
     HNDG Q 0 A_TakeInventory("thrownade")
     Goto Ready
  Useknife:
     KNFG A 0 A_jumpifinventory("Machete",1,"UseMachete")
     KNFG ABC 2
	 KNFG C 0 A_CustomPunch (110,1,0,"KnifePuff")
	 KNFG DEF 2
	 KNFG F 0 A_TakeInventory("Kinfeammo")
	 goto ready
  UseMachete:
     MHT4 ABC 2
	 MHT4 C 0 A_CustomPunch (450,1,0,"Machetepuff")
	 MHT4 DEFG 2
	 MHT4 G 0 A_TakeInventory("Kinfeammo")
	 goto ready
  Spawn:
    GEWE Z -1
	stop
  }
}

actor PAPHeat : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 200
    ammo.backpackamount 0
    ammo.backpackmaxamount 200
    +IGNORESKILL
}

actor PAPHeatlimt : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 200
    inventory.maxamount 200
    ammo.backpackamount 200
    ammo.backpackmaxamount 200
    +IGNORESKILL
}