ACTOR "Vexed Nemesis Rifle" : "Legendary Plasmatic Rifle"
{
//$Category Weapons/BFG20K
//$Title "Vexed Nemesis Rifle"
//$Sprite VTEPA0
Weapon.AmmoGive 200
Weapon.AmmoUse 1
Weapon.AmmoType "VexNemDemonMagazine"   
Weapon.AmmoType2 "VexNemDemonAmmo"
Inventory.PickupSound "VexedRifle/up"
Inventory.PickupMessage "You got the \c[w2]Vexed Nemesis Rifle!"
Obituary "%k was destroyed quickly by %o's storm of dark energy"
+INVENTORY.UNDROPPABLE
States
	{
	Spawn:
		VTEP A -1
		Loop
	Ready:
		TNT1 A 0 A_PlaySound("VexedRifle/up")
		VTRS ABCDE 1
	ReadyLoop:
		TNT1 A 0 A_JumpIfInventory("VexNemDemonMagazine",1,2)
		TNT1 A 0
		Goto NoBuzzing
		VTEK AAA 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK AAA 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK AAA 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK AAA 1 A_WeaponReady	 
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK AAA 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK AAA 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK AAA 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK AAA 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK AAA 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK AAA 1 A_WeaponReady
		TNT1 A 0 A_PlaySound("weapons/legrifidle")
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK BB 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK BB 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK CC 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK CC 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK DD 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK DD 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK EE 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK EE 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		Goto ReadyLoop
	NoBuzzing:
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		VTEK A 1 A_WeaponReady
		Loop
	Deselect:
		TNT1 A 0// A_PlaySound ("D_LEGND",5,5.0,1,ATTN_NONE)
		//TNT1 A 0 ACS_NamedExecuteAlways("StopWeaponMusic",0)
		VTEK A 1 A_Lower
		Goto Deselect+1
	Select:
		TNT1 A 0
		TNT1 A 0 A_Raise
		Wait
	Fire:
		TNT1 A 0 Bright A_JumpIfNoAmmo("Empty")
		//TNT1 A 0 ACS_NamedExecuteAlways("StartWeaponMusic",0,0)
		TNT1 A 0 Bright A_AlertMonsters
		TNT1 A 0 Bright A_GunFlash
		TNT1 A 0 Bright Radius_Quake(4,4,0,1,0)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 Bright A_PlayWeaponSound("VexedRifle/Fire")
		VTKF AA 1 Bright A_FireCustomMissile("VexedRifleShot",Random(100,-100)/100.00,1,0,0,0,Random(100,-100)/100.00)
		VTKF B 1 Bright A_Light2
		VTKF C 2 A_Light0
		TNT1 A 0 A_ReFire
		Goto ReadyLoop
	Empty:
		TNT1 A 0 A_PlaySound("weapons/click2")
		VTEK AAAAAAAAAA 1 A_WeaponReady(WRF_NOFIRE)
	AltFire:
		TNT1 A 0 A_JumpIfInventory("VexNemDemonMagazine",100,2)
		TNT1 A 0 A_JumpIfInventory("VexNemDemonAmmo",1,2)
		TNT1 A 0
		Goto ReadyLoop
		VTKR AB 2
		VTKR C 3
		VTKR D 4 A_PlaySound("weapons/demontecheject")
		TNT1 A 0 Radius_Quake(2,2,0,1,0)
		VTKR E 2 A_PlaySound("weapons/demontechsteam")
		VTKR F 2 Radius_Quake(2,2,0,1,0)
		VTKR GHI 2 Radius_Quake(2,2,0,1,0)
		VTKR J 3 A_FireCustomMissile("LDemonTechEmptyMag", 0, 0, 0, 1)
		VTKR K 15 
		VTKR LMN 2
		TNT1 A 0 A_JumpIfInventory("VexNemDemonAmmo",1,"Reload")	 
		VTKR O 6 A_PlayWeaponSound("weapons/demontechload")
		VTKR O 4 A_PlayWeaponSound("weapons/demontechclick")
		VTKR CB 3
		VTKR A 2
		Goto ReadyLoop
	Reload:
		TNT1 A 0 A_TakeInventory("VexNemDemonAmmo",1)
		TNT1 A 0 A_GiveInventory("VexNemDemonMagazine",1)
		TNT1 A 0 A_JumpIfInventory("VexNemDemonMagazine",100,"Full")
		TNT1 A 0 A_JumpIfInventory("VexNemDemonAmmo",1,"Reload")
		Goto AltFire+19
	Full:
		TNT1 A 0
		Goto AltFire+19
	GrenadeCheck:
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
		TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
		Goto Ready+6
	GrenadeToss:
		TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
		VTRS EDCBA 1
		TNT1 A 6
		HGRN ABC 1
		HGRN D 3
		HGRN EFGHI 2
		TNT1 A 14 A_PlayWeaponSound("weapons/hgrenadepin")
		TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
		TNT1 A 0 A_TakeInventory("HandGrenadeAmmo",1,TIF_NOTAKEINFINITE)
		HGRN J 1 A_FireCustomMissile("ThrownGrenade",0,0,0,0,false)
		HGRN K 1
		HGRN LMNO 2
		TNT1 A 6
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,2)
		TNT1 A 0// A_TakeInventory("Hand Grenade",1)
		TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
		TNT1 A 0
		Goto Ready+1
	MineCheck:
		TNT1 A 0 A_JumpIfInventory("MineAmmo",1,"MineToss")
		TNT1 A 0 A_TakeInventory("MineAction",1)
		Goto Ready+6
	MineToss:
		TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
		VTRS EDCBA 1
		TNT1 A 10
		TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
		MINE ABCDEF 1		
		TNT1 A 0 A_TakeInventory("MineAmmo",1,TIF_NOTAKEINFINITE)	  
		MINE G 1 A_FireCustomMissile("ThrownMine",0,0,0,0,false)
		MINE HI 1
		MINE JK 2
		TNT1 A 0 A_JumpIfInventory("MineAmmo",1,2)
		TNT1 A 0// A_TakeInventory("Land Mine",1)
		TNT1 A 0 A_TakeInventory("MineAction",1)
		TNT1 A 0
		TNT1 A 5
		Goto Ready+1 
	}
}

ACTOR VexedRifleShot
{
PROJECTILE
Height 3
Radius 3
Speed 70
Scale 0.55
RenderStyle Subtract
Alpha 0.95
Decal "DoomImpScorch"
Damage 85
+FORCERADIUSDMG
+NOTIMEFREEZE
+THRUSPECIES
+FOILINVUL
+PIERCEARMOR
Species "Player"
DamageType "PlayerNemesisPlasma"
DeathSound "weapons/demontechex"
States
	{
	Spawn:
		TNT1 A 0 Bright
		TNT1 A 0 Bright A_Jump(128,"Spawn2")
		Goto Normal
	Normal:
		NTPR ABCDEF 1 Bright A_SpawnItemEx("NemesisWhiteProjParticleSuperLarge",Random(-1,1),Random(-1,1),Random(-1,1),Random(-1,1),Random(-1,1),Random(-1,1),Random(-20,20),SXF_CLIENTSIDE|SXF_NOCHECKPOSITION,0)
		Loop
	Spawn2:
		NTPR ABCDEF 1 Bright A_SpawnItemEx("NemesisWhiteProjParticleSuperLarge",Random(-1,1),Random(-1,1),Random(-1,1),Random(-1,1),Random(-1,1),Random(-1,1),Random(-20,20),SXF_CLIENTSIDE|SXF_NOCHECKPOSITION,0)
		Loop	  
	Death:
		TNT1 A 0 Bright
		TNT1 A 0 Bright A_SpawnItemEx("NemesisWhiteParticleSpawner",0,0,0,0,0,0,0,SXF_CLIENTSIDE,0)
		TNT1 AAA 0 A_CustomMissile("NemesisKaboom7",0,0,random(0,360),CMF_AIMDIRECTION,random(0,360))
		TNT1 AAA 0 A_CustomMissile("LegendarySmokeFX4",0,0,random(0,360),2,random(0,360))
		TNT1 A 0 Bright A_SpawnItemEx("NemesisADemonTechEx",0,0,0,0,0,0,0,SXF_CLIENTSIDE,0)
		TNT1 A 0 Bright A_JumpIf(ACS_ExecuteWithResult(304) == 0, "DeathSFX")
		Goto Toaster
	DeathSFX:
		TNT1 A 0 Bright A_SpawnItemEx("NemesisWhiteParticleSpawner",0,0,0,0,0,0,0,SXF_CLIENTSIDE,0)
		TNT1 AAA 0 A_CustomMissile("NemesisKaboom7",0,0,random(0,360),CMF_AIMDIRECTION,random(0,360))
		TNT1 AAA 0 A_CustomMissile("LegendarySmokeFX4",0,0,random(0,360),CMF_AIMDIRECTION,random(0,360))
		TNT1 A 0 Bright A_SpawnItemEx("NemesisADemonTechEx",0,0,0,0,0,0,0,SXF_CLIENTSIDE,0)
	Toaster:
		TNT1 A 1 Bright A_CustomMissile("VexedRifleShotExplosion",0,0,0,2)
		Stop
	}
}

ACTOR VexedRifleShotExplosion
{
Projectile
Speed 0
+FORCERADIUSDMG
+NOTIMEFREEZE
+NODAMAGETHRUST
+FOILINVUL
+PIERCEARMOR
+DONTHURTSPECIES
Damagetype "PlayerNemesisPlasma"
Species "Player"
States
{
Spawn:
Death:
	TNT1 A 0
	TNT1 A 1 A_Explode(200,100)
	Stop
}
}
ACTOR VexNemDemonMagazine : Ammo 
{
+IGNORESKILL
Inventory.Amount 0
Inventory.MaxAmount 100
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 100
Inventory.Icon "VTEPA0"
}

ACTOR VexNemDemonAmmo : Ammo
{
Scale 0.65
+NOTIMEFREEZE
Inventory.Amount 50
Inventory.MaxAmount 250
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 500
Inventory.Icon "VAMGA0"
Inventory.PickupSound "items/legendaryammo"
Inventory.PickupMessage "Charged Vexed Nemesis Energy Cells"
States
	{
	Spawn:
		VAMG A -1
		Stop
	}
}

ACTOR VexNemDemonAmmoBox : VexNemDemonAmmo
{
Scale 0.65
Inventory.Amount 100
Inventory.PickupMessage "Charged Vexed Nemesis Energy Cells Box"
Inventory.PickupSound "items/legendaryammopack"
+NOTIMEFREEZE
States
	{
	Spawn:
		VAMO A -1
		Stop
	}
}