Actor Omen : Weapon Replaces Chaingun 25009
{
  
	Tag "OMN-106E Omen Mk. 3"
	Weapon.SelectionOrder 400
	Weapon.SlotNumber 4
	Inventory.PickupSound "misc/w_pkup"
	Inventory.PickupMessage "You got the OMN-106E 'Omen Mk.3' Assault Rifle"
	Weapon.UpSound "Weapons/OmenUp"
	Obituary "%k decided to teach %o a lesson in the art of being a bullet sponge, %g passed with flying colors."
	Weapon.AmmoType "OmenClip"
	Weapon.AmmoGive 0
	Weapon.AmmoUse 1
	Weapon.PreferredSkin "Rifle"
	Weapon.AmmoType2 "ARifle_Magazine"
	Weapon.AmmoGive2 2
	Weapon.AmmoUse2 0
	decal "BlazeChip"
	Scale 0.75
	Weapon.Slotnumber 4
	weapon.bobstyle inversesmooth
	weapon.bobrangeX 0.4
	weapon.bobrangeY 0.6
	weapon.bobspeed 2.5
	+AMMO_OPTIONAL
	+NOEXTREMEDEATH
	+NoAutoFire
	+NOALERT
	+NOAUTOAIM
	States
	{
	Ready:
        HNGI A 1 A_WeaponReady(WRF_ALLOWRELOAD)
        loop
	ReadyEmpty:
        HNGE A 1 A_WeaponReady(WRF_ALLOWRELOAD)
        loop
    Deselect:
        TNT1 A 0 SetPlayerProperty(0,1,2)
	    TNT1 A 0 A_SetCrosshair(1)
	    HNGS FEDCBA 1
	    Goto DeselectLoop
    DeselectLoop:
        TNT1 A 1 A_Lower
        Loop
    Select:
		TNT1 A 0 A_JumpIfInventory("RifleToken",1,"SelectSemi")
		TNT1 A 0 A_JumpIfInventory("OmenFirstTime",1,1)
		goto SelectAuto
		TNT1 A 0 A_PlaySoundEx("Weapons/OmenFirst","WeaponPickedUp",0,0)
		TNT1 A 0 SetPlayerProperty(0,0,2)
		TNT1 A 0 A_SetCrosshair(7)
		HNGS ABCDEF 1
		TNT1 A 0 A_TakeInventory("OmenFirstTime",1)
		Goto SelectLoop
	SelectAuto:
		TNT1 A 0 SetPlayerProperty(0,0,2)
		TNT1 A 0 A_SetCrosshair(7)
		HNGS ABCDEF 1
		Goto SelectLoop
	SelectSemi:
		TNT1 A 0 SetPlayerProperty(0,0,2)
		TNT1 A 0 A_SetCrosshair(14)
		HNGS ABCDEF 1
		Goto SelectLoop
    SelectLoop:
        HNGI A 1 A_Raise
	    loop
	Spawn:
		OMNP A -1
		Stop
	Fire:
	    TNT1 A 0 A_JumpIfInventory("RifleToken", 1, "FireSemi")
	FireAuto:
	    TNT1 A 0 A_JumpIfInventory("OmenClip",2,1)
		Goto FireAutoLast
		TNT1 A 0 A_JumpIfInventory("OmenClip",1,1)
		Goto DryFire
		TNT1 A 0 A_AlertMonsters
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
	    TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
		TNT1 A 0 A_PlaySound("Weapons/OmenFire",92,0.99,0,1)
		TNT1 A 0 A_PlaySound("Weapons/OmenFireAdd",93,0.66,0,1)
		TNT1 A 0 A_SpawnItemEx("arifle_casing", 20,-20,32, 8,random(-2,2),random(0,4), random(-55,-80), SXF_NOCHECKPOSITION)
		TNT1 A 0 A_FireCustomMissile("p_arifle_tracer", random(-1, 1), 1, 2.5, 5, 0,random(-1, 1))
		TNT1 A 0 A_SetPitch(pitch - 0.85)
		HNGF A 1 Bright A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.99)
		HNGF B 1 Bright A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.98)
		HNGF C 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.97)
		HNGF D 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.98)
		TNT1 A 0 A_Refire
		TNT1 A 0 A_ZoomFactor(0.99)
		TNT1 A 0 A_ZoomFactor(1.00)
		Goto Ready
	FireAutoLast:
		TNT1 A 0 A_JumpIfInventory("OmenClip",1,1)
		Goto DryFire
		TNT1 A 0 A_AlertMonsters
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
	    TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
		TNT1 A 0 A_PlaySound("Weapons/OmenFire",92,0.99,0,1)
		TNT1 A 0 A_PlaySound("Weapons/OmenFireAdd",93,0.66,0,1)
		TNT1 A 0 A_PlaySound("Weapons/OmenBolt",94,1.5,0,1)
		TNT1 A 0 A_SpawnItemEx("arifle_casing", 20,-20,32, 8,random(-2,2),random(0,4), random(-55,-80), SXF_NOCHECKPOSITION)
		TNT1 A 0 A_FireCustomMissile("p_arifle_tracer", random(-1, 1), 1, 2.5, 5, 0,random(-1, 1))
		TNT1 A 0 A_SetPitch(pitch - 0.85)
		HNGF A 1 Bright A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.99)
		HNGF B 1 Bright A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.98)
		HNGF E 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.97)
		HNGF F 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.98)
		TNT1 A 0 A_Refire
		TNT1 A 0 A_ZoomFactor(0.99)
		TNT1 A 0 A_ZoomFactor(1.00)
		Goto ReadyEmpty
	FireSemi:
	    TNT1 A 0 A_JumpIfInventory("OmenClip",2,1)
		Goto FireSemiLast
		TNT1 A 0 A_JumpIfInventory("OmenClip",1,1)
		Goto DryFire
		TNT1 A 0 A_AlertMonsters
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
	    TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
		TNT1 A 0 A_PlaySound("Weapons/OmenFire",92,0.99,0,1)
		TNT1 A 0 A_PlaySound("Weapons/OmenFireAdd",93,0.66,0,1)
		TNT1 A 0 A_SpawnItemEx("arifle_casing", 20,-20,32, 8,random(-2,2),random(0,4), random(-55,-80), SXF_NOCHECKPOSITION)
		TNT1 A 0 A_FireCustomMissile("p_arifle_tracer", random(-0.5, 0.5), 1, 2.5, 5, 0,random(-0.5, 0.5))
		TNT1 A 0 A_SetPitch(pitch - 0.85)
		HNGF A 1 Bright A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.99)
		HNGF B 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.98)
		HNGF C 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.97)
		HNGF D 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.98)
		TNT1 A 0 A_ZoomFactor(0.99)
		TNT1 A 0 A_ZoomFactor(1.00)
		Goto Ready
	FireSemiLast:
		TNT1 A 0 A_JumpIfInventory("OmenClip",1,1)
		Goto DryFire
		TNT1 A 0 A_AlertMonsters
		TNT1 AA 0 A_FireCustomMissile("gausssmoke_spawner2",0,0,3,4,0)		
	    TNT1 A 0 A_SpawnItem("Lightprojectile",0,0,0,0)
		TNT1 A 0 A_PlaySound("Weapons/OmenFire",92,0.99,0,1)
		TNT1 A 0 A_PlaySound("Weapons/OmenFireAdd",93,0.66,0,1)
		TNT1 A 0 A_PlaySound("Weapons/OmenBolt",94,1.5,0,1)
		TNT1 A 0 A_SpawnItemEx("arifle_casing", 20,-20,32, 8,random(-2,2),random(0,4), random(-55,-80), SXF_NOCHECKPOSITION)
		TNT1 A 0 A_FireCustomMissile("p_arifle_tracer", random(-0.5, 0.5), 1, 2.5, 5, 0,random(-0.5, 0.5))
		TNT1 A 0 A_SetPitch(pitch - 0.85)
		HNGF A 1 Bright A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.99)
		HNGF B 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.98)
		HNGF E 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.97)
		HNGF F 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_ZoomFactor(0.98)
		TNT1 A 0 A_ZoomFactor(0.99)
		TNT1 A 0 A_ZoomFactor(1.00)
		Goto ReadyEmpty
	AltFire: //Does checks, if you have no dummy actors, select semi auto
		TNT1 A 0 A_PlaySoundEX("Weapons/FireSelector","Body",0,0)
		SHTG A 0 A_JumpIfInventory("RifleToken", 1, "AltFire2")
		SHTG A 0 A_GiveInventory("RifleToken", 1)
		TNT1 A 0 A_SetCrosshair(14)
		HNGI A 10 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
	AltFire2: //Clears dummy actors, to use full auto
		TNT1 A 0 A_PlaySoundEX("Weapons/FireSelector","Body",0,0)
		SHTG A 0 A_TakeInventory("RifleToken", 1)
		TNT1 A 0 A_SetCrosshair(7)
		HNGI A 10 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
	DryFire:
		TNT1 A 0 A_PlaySound("Rifle/Empty",199,1.0,0,1)
		HNGE A 5 A_WeaponReady(WRF_NOFIRE)
		Goto ReadyEmpty
	Reload:
	ReloadBegin:
		NULL A 0
		TNT1 A 0 A_JumpIfInventory("OmenClip",64,"Ready")
		TNT1 A 0 A_JumpIfInventory("Arifle_Magazine",1,1)
		Goto DryFire
		TNT1 A 0 A_PlaySound("Weapons/SniperPull",94,0.75,0,1)
		HNGR ABCD 1 A_WeaponReady(WRF_NOFIRE)
		HNGR E 2 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("ArchangelK61/MagOut",95,0.75,0,1)
		HNGR E 2 A_WeaponReady(WRF_NOFIRE)
		HNGR FGH 2 A_WeaponReady(WRF_NOFIRE)
		4XRR E 0 A_SpawnItemEx("OmenClipDrop",0,0,20)
		HNGR H 20 A_WeaponReady(WRF_NOFIRE)
		HNGR IJK 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("ArchangelK61/MagIn",96,0.75,0,1)
		HNGR L 2 A_WeaponReady(WRF_NOFIRE)
		HNGR M 2 A_WeaponReady(WRF_NOFIRE)
		HNGR N 2 A_WeaponReady(WRF_NOFIRE)
		HNGR OP 2 A_WeaponReady(WRF_NOFIRE)
		HNGR Q 2 A_WeaponReady(WRF_NOFIRE)
	ReloadAmmoLoop:
		NULL A 0 A_TakeInventory("ARifle_Magazine",1)
		NULL A 0 A_GiveInventory("OmenClip",64)
		NULL A 0 A_JumpIfInventory("ARifle_Magazine",1,1) // if not out of ammo, countinue reloading
		goto ReloadEnd
		NULL A 0 A_JumpIfInventory("OmenClip",64,"ReloadEnd") // if clip full, finish reload
		goto ReloadAmmoLoop // otherwise continue
	ReloadEnd:
	
		TNT1 A 0 A_PlaySound("ArchangelK61/BoltCatch",99,0.99,0,1)
		HNGR RSTU 1 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
	}
}

ACTOR RifleToken : Inventory {Inventory.MaxAmount 1}

ACTOR OmenFirstTime : Inventory {Inventory.MaxAmount 1 Inventory.InterHubAmount 1}

ACTOR OmenClip : Ammo
{
Inventory.Amount 0
Inventory.MaxAmount 64
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 64
+IGNORESKILL
}

actor ARifle_Magazine : ammo 26103 {
  radius 16
  height 8
  Scale 0.55
  inventory.pickupmessage "Drum Magazine of 7.62x45mm SS-AP Ammo for the OMN-106E Omen Mk.2"
  inventory.pickupsound "ArchangelK61/MagIn"
  inventory.amount 1
  inventory.maxamount 5
  ammo.backpackamount 2
  ammo.backpackmaxamount 10
  states
  {
  Spawn:
    OMNC A -1
    stop
  }
}

ACTOR ARifle_Casing
{
   Radius 2
   Height 4
   Speed 8
   Scale 0.16
   BounceSound "Weapons/RifleCasing"
   PROJECTILE
   -NOGRAVITY
   +BOUNCEONACTORS
   +BOUNCEONCEILINGS
   +DONTSPLASH
   +CLIENTSIDEONLY
   Gravity 0.75
   BounceType Doom
   BounceCount 6
   BounceFactor 0.6
   DamageType Nope
   States
   {
   Spawn:
	  ARBC A 0
      ARBC ABCDEF 1
      Goto Roflcopter
   Roflcopter:
      ARBC A 0 A_Jump(128,1,3,5,7)
      ARBC ABCDEF 1
      Loop
   Death:
      ARBC A 0 A_SpawnItemEx("ARifle_Casing_Liedown")
      stop
   }
}

actor ARifle_Casing_Liedown
{
	-NOGRAVITY
    Scale 0.16
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_Jump(255,"Spawn1","Spawn2","Spawn3")
	  stop
	Spawn1:
	  ARBC A 1
	  Goto Ded
	Spawn2:
	  ARBC D 1
	  Goto Ded
	Spawn3:
	  ARBC C 1
	  Goto Ded
	Ded:
	  "####" "#" 210 A_CheckSight("Fadying")
	  Loop
	Fadying:
	  "####" "#" 1 A_FadeOut(0.1)
	  Wait
   }
}

ACTOR OmenClipDrop
{
   Radius 4
   Height 6
   Speed 0
   Scale 0.24
   BounceSound "Clip/ASR"
   PROJECTILE
   -NOGRAVITY
   +BOUNCEONACTORS
   +BOUNCEONCEILINGS
   +NOTIMEFREEZE
   Gravity 0.75
   BounceType Doom
   BounceCount 4
   BounceFactor 0.6
   States
   {
   Spawn:
      CLP3 A 0
      CLP3 ABCDEFGH 1
      Loop
   Death:
      CLP3 A 0 A_SpawnItemEx("OmenClipLiedown")
      stop
   }
}

actor OmenClipLiedown
{
	-NOGRAVITY
	+FLOORCLIP
	+NOTIMEFREEZE
    Scale 0.22
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_Jump(255,"Spawn1","Spawn2")
	  stop
	Spawn1:
	  CLP3 I 1
	  Goto Ded
	Spawn2:
	  CLP3 J 1
	  Goto Ded
	Ded:
	  "####" "#" 210 A_CheckSight("Fadying")
	  Loop
	Fadying:
	  "####" "#" 1 A_FadeOut(0.1)
	  Wait
   }
}