actor PlasmaGun : Weapon
{
  Game Doom
  Weapon.SelectionOrder 1400
  weapon.ammotype "PlasmaClip"
  weapon.ammouse 1
  weapon.ammogive2 999
  weapon.ammogive1 60
  weapon.ammotype2 "PlasmaAmmo"
  States
  {
  Ready:
	PKPL A 0 A_JumpIfInventory("thrownade",1,"ThrowGrenade")
    PKPL A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
	AK47 A 0 A_JumpIfInventory("Kinfeammo",1,"UseKnife") 	
    PKPL A 1 A_WeaponReady
    Loop
  Deselect: 
    PKPL A 0 A_Lower
    PKPL A 0 A_Lower
    PKPL A 1 A_Lower
    loop
  Select:
    PKPL A 0 A_Raise
    PKPL A 0 A_Raise
    PKPL A 1 A_Raise
    loop
  Fire:
    PIRE A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletap")	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
	PKPL A 0 A_GunFlash
	NULL A 0 A_PlaySoundEx("weapons/plasma/fire","Weapon")
	PKPL A 0 A_FireCustomMissile("KewlPlasma")
	NULL A 0 A_GiveInventory("FireNumber",1)
	PKPL A 3	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
	PKPL B 1 A_ReFire	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
	NULL A 0 A_TakeInventory("FireNumber",2)
	PKPL DEF 1
	PKPL GF 3
	PKPL EDCBA 2	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
  Goto Ready
  Fire_Doubletap:
	PKPL A 0 A_GunFlash
	NULL A 0 A_PlaySoundEx("weapons/plasma/fire","Weapon")
	PKPL A 0 A_FireCustomMissile("KewlPlasma")
	NULL A 0 A_GiveInventory("FireNumber",1)
	PKPL A 3	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
	PKPL B 1 A_ReFire	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
	NULL A 0 A_TakeInventory("FireNumber",2)
	PKPL DEF 1
	PKPL GF 2
	PKPL EDCBA 1	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
  Goto Ready
  Reload:
    PIRE A 0 A_takeinventory("IsReloading",1)
    PIRE A 0 A_jumpifinventory("SpeedCola",1,"Reload_speed")
	PIRE A 0 A_jumpifInventory("PlasmaClip",60,"Ready")
    PIRE A 0 A_JumpIfInventory("Plasmaammo", 1, 1)
	goto Ready
    PKPL A 0 A_playsoundEX("weapons/plasma/clipout","Weapon")
	PKPL BCD 2
	PLRE EDCBA 2
	PLRE A 15
	goto reload2
  Reload2:
	PLRE A 0 A_GiveInventory("PlasmaClip",1)
	PLRE A 0 A_TakeInventory("Plasmaammo",1)
	PLRE A 0 A_jumpifInventory("PlasmaClip",60,"ReloadDone")
    PLRE A 0 A_JumpIfInventory("Plasmaammo", 1, "Reload2")
  goto reloaddone
  Reloaddone:
	PLSR ABCDEF 2
	PLSR F 0 A_playsoundEX("weapons/plasma/clipin","Weapon")
	PLSR GGGHHHGG 2
	PLRE A 3
	PLRE ABCDE 2
	PKPL DCB 2
  goto ready
  Reload_speed:
    PIRE A 0 A_takeinventory("IsReloading",1)
	PIRE A 0 A_jumpifInventory("PlasmaClip",60,"Ready")
    PIRE A 0 A_JumpIfInventory("Plasmaammo", 1, 1)
	goto Ready
    PKPL A 0 A_playsoundEX("weapons/plasma/clipout","Weapon")
	PKPL BCD 1
	PLRE EDCBA 1
	PLRE A 7
	goto reload2_speed
  Reload2_speed:
	PLRE A 0 A_GiveInventory("PlasmaClip",1)
	PLRE A 0 A_TakeInventory("Plasmaammo",1)
	PLRE A 0 A_jumpifInventory("PlasmaClip",60,"ReloadDone_speed")
    PLRE A 0 A_JumpIfInventory("Plasmaammo", 1, "Reload2_speed")
  goto reloaddone_speed
  Reloaddone_speed:
	PLSR ABCDEF 1
	PLSR F 0 A_playsoundEX("weapons/plasma/clipin","Weapon")
	PLSR GGGHHHGG 1
	PLRE A 2
	PLRE ABCDE 1
	PKPL DCB 1
  goto ready
  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
  Flash:
	NULL A 0
	NULL A 0 A_JumpIfInventory("FireNumber",0,"MatureFlash")
	NULL A 0 A_Jump(128,"Flash2")
	PLSF ACAC 1 Bright A_Light1
  Goto LightDone
  Flash2:
	PLSF CAAC 1 Bright A_Light1
    Goto LightDone
  MatureFlash:
	NULL A 0 A_Jump(128,"MatureFlash2")
	PLSF DBEF 1 Bright A_Light1
    Goto LightDone
  MatureFlash2:
	PLSF EDFB 1 Bright A_Light1
    Goto LightDone
  Spawn:
    PLAS A -1
    Stop
  }
}
actor PlasmaClip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 60
    ammo.backpackamount 0
    ammo.backpackmaxamount 60
    +IGNORESKILL
}


actor PlasmaAmmo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 60
    inventory.maxamount 600
    ammo.backpackamount 60
    ammo.backpackmaxamount 600
    +IGNORESKILL
    inventory.pickupmessage "Got Plasma rounds!"  
    States
    {
    Spawn:
      CLIP A -1
      Stop
    }
}
Actor KewlPlasma : PlasmaBall
{
	SeeSound ""
	DeathSound "weapons/plasma/impact"
	RenderStyle Add
	Alpha 0.5
	Scale 0.12
	Speed 25
	Damage (Random(1500,1500))
	//MissileType "PlasmaVapor"
	States
	{
	Spawn:
		PLAB ABCDE 1 bright A_SpawnItemEx ("PlasmaVapour", 0, 0, 0,  (momx*0.5), (momy*0.5), (momz*0.5), 0, SXF_ABSOLUTEMOMENTUM)
		NULL A 0 A_SpawnItem("PlasmaWave")
		Loop
	Death:
		NULL AAAAAAAAAA 0 A_CustomMissile("PlasmaExplosion",0,0,(Random(0,360)),2,(Random(0,360)))
		//A_SpawnItemEx ("PlasmaExplosion", 0, 0, 0,  (Random(-1,1)), (Random(-1,1)), (Random(-1,1)), 0, SXF_ABSOLUTEMOMENTUM|SXF_NOCHECKPOSITION)
		//NULL A 0 A_SpawnItem("PlasmaExplosion")
		NULL A 10
		stop
	}
}


Actor FireNumber : Inventory
{
	Inventory.MaxAmount 2
}

Actor PlasmaVapour
{
	+CLIENTSIDEONLY
	projectile
	RenderStyle Add
	Alpha 0.2
	Scale 0.1
	States
	{
	Spawn:
		NULL A 3
	Loopy:
		PLAV ABCDEFGHIJKL 1 bright A_FadeOut(0.01)
		loop
	}
}

Actor PlasmaWave
{
	+CLIENTSIDEONLY
	projectile
	//+DOOMBOUNCE
	//+BOUNCEONACTORS
	RenderStyle Add
	Alpha 0.25
	Scale 0.1
	States
	{
	Spawn:
		NULL A 3
		PBBT A 2 bright A_FadeOut(0.01)
		goto Spawn+1
	}
}

Actor PlasmaExplosion
{
	+NOBLOCKMAP
	+NOINTERACTION
	+CLIENTSIDEONLY
	RenderStyle Add
	Radius 1
	Height 1
	Speed 0.25
	Alpha 0.15
	Scale 0.4
	States
	{
	Spawn:
		PLAX ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 bright
		PLAZ ABCDEF 1 bright
		stop
	}
}

actor PAPPlasmaGun : Weapon
{
  Game Doom
  Weapon.SelectionOrder 1900
  weapon.ammotype "PAPPlasmaClip"
  weapon.ammouse 1
  weapon.ammogive2 999
  weapon.ammogive1 60
  weapon.ammotype2 "PlasmaAmmo"
  States
  {
  Ready:
	PKPL A 0 A_JumpIfInventory("thrownade",1,"ThrowGrenade")
    PKPL A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
	AK47 A 0 A_JumpIfInventory("Kinfeammo",1,"UseKnife")
    PKPL A 1 A_WeaponReady
    Loop
  Deselect: 
    PKPL A 0 A_Lower
    PKPL A 0 A_Lower
    PKPL A 1 A_Lower
    loop
  Select:
    PKPL A 0 A_Raise
    PKPL A 0 A_Raise
    PKPL A 1 A_Raise
    loop
  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
  Fire:	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
    PIRE A 0 A_jumpifinventory("Doubletap",1,"Fire_Doubletap")
	PKPL A 0 A_GunFlash
	NULL A 0 A_PlaySoundEx("weapons/plasma/fire","Weapon")
	PKPL A 0 A_FireCustomMissile("KewlPlasma2")
	NULL A 0 A_GiveInventory("FireNumber",1)
	PKPL A 3	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
	PKPL B 1 A_ReFire	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
	NULL A 0 A_TakeInventory("FireNumber",2)
	PKPL DEF 1
	PKPL GF 3
	PKPL EDCBA 2	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
  Goto Ready
  Fire_Doubletap:	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
	PKPL A 0 A_GunFlash
	NULL A 0 A_PlaySoundEx("weapons/plasma/fire","Weapon")
	PKPL A 0 A_FireCustomMissile("KewlPlasma2")
	NULL A 0 A_GiveInventory("FireNumber",1)
	PKPL A 3	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
	PKPL B 1 A_ReFire	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
	NULL A 0 A_TakeInventory("FireNumber",2)
	PKPL DEF 1
	PKPL GF 2
	PKPL EDCBA 1	
    PKPL A 0 A_JumpIfNoAmmo("Reload") 
  Goto Ready
  Reload:
    PIRE A 0 A_takeinventory("IsReloading",1)
    PIRE A 0 A_jumpifinventory("SpeedCola",1,"Reload_speed")
	PIRE A 0 A_jumpifInventory("PAPPlasmaClip",60,"Ready")
    PIRE A 0 A_JumpIfInventory("Plasmaammo", 1, 1)
	goto Ready
    PKPL A 0 A_playsoundEX("weapons/plasma/clipout","Weapon")
	PKPL BCD 2
	PLRE EDCBA 2
	PLRE A 15
	goto reload2
  Reload2:
	PLRE A 0 A_GiveInventory("PAPPlasmaClip",1)
	PLRE A 0 A_TakeInventory("Plasmaammo",1)
	PLRE A 0 A_jumpifInventory("PAPPlasmaClip",60,"ReloadDone")
    PLRE A 0 A_JumpIfInventory("Plasmaammo", 1, "Reload2")
  goto reloaddone
  Reloaddone:
	PLSR ABCDEF 2
	PLSR F 0 A_playsoundEX("weapons/plasma/clipin","Weapon")
	PLSR GGGHHHGG 2
	PLRE A 3
	PLRE ABCDE 2
	PKPL DCB 2
  goto ready
  Reload_speed:
    PIRE A 0 A_takeinventory("IsReloading",1)
	PIRE A 0 A_jumpifInventory("PAPPlasmaClip",60,"Ready")
    PIRE A 0 A_JumpIfInventory("Plasmaammo", 1, 1)
	goto Ready
    PKPL A 0 A_playsoundEX("weapons/plasma/clipout","Weapon")
	PKPL BCD 1
	PLRE EDCBA 1
	PLRE A 7
	goto reload2_speed
  Reload2_speed:
	PLRE A 0 A_GiveInventory("PAPPlasmaClip",1)
	PLRE A 0 A_TakeInventory("Plasmaammo",1)
	PLRE A 0 A_jumpifInventory("PAPPlasmaClip",60,"ReloadDone_speed")
    PLRE A 0 A_JumpIfInventory("Plasmaammo", 1, "Reload2_speed")
  goto reloaddone_speed
  Reloaddone_speed:
	PLSR ABCDEF 1
	PLSR F 0 A_playsoundEX("weapons/plasma/clipin","Weapon")
	PLSR GGGHHHGG 1
	PLRE A 2
	PLRE ABCDE 1
	PKPL DCB 1
  goto ready
  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
  Flash:
	NULL A 0
	NULL A 0 A_JumpIfInventory("FireNumber",0,"MatureFlash")
	NULL A 0 A_Jump(128,"Flash2")
	PLSF ACAC 1 Bright A_Light1
  Goto LightDone
  Flash2:
	PLSF CAAC 1 Bright A_Light1
    Goto LightDone
  MatureFlash:
	NULL A 0 A_Jump(128,"MatureFlash2")
	PLSF DBEF 1 Bright A_Light1
    Goto LightDone
  MatureFlash2:
	PLSF EDFB 1 Bright A_Light1
    Goto LightDone
  Spawn:
    PLAS A -1
    Stop
  }
}
actor PAPPlasmaClip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 60
    ammo.backpackamount 0
    ammo.backpackmaxamount 60
    +IGNORESKILL
}

Actor KewlPlasma2 : PlasmaBall
{
	SeeSound ""
	DeathSound "weapons/plasma/impact"
	RenderStyle Add
	Alpha 0.5
	Scale 0.12
	Speed 25
	Damage (Random(4500,4500))
	//MissileType "PlasmaVapor"
	States
	{
	Spawn:
		PLAB ABCDE 1 bright A_SpawnItemEx ("PlasmaVapour", 0, 0, 0,  (momx*0.5), (momy*0.5), (momz*0.5), 0, SXF_ABSOLUTEMOMENTUM)
		PLAB A 0 A_givetotarget("money",10)
		NULL A 0 A_SpawnItem("PlasmaWave")
		Loop
	Death:
		NULL AAAAAAAAAA 0 A_CustomMissile("PlasmaExplosion",0,0,(Random(0,360)),2,(Random(0,360)))
		//A_SpawnItemEx ("PlasmaExplosion", 0, 0, 0,  (Random(-1,1)), (Random(-1,1)), (Random(-1,1)), 0, SXF_ABSOLUTEMOMENTUM|SXF_NOCHECKPOSITION)
		//NULL A 0 A_SpawnItem("PlasmaExplosion")
		NULL A 10
		stop
	}
}