// --------------------------------------------------------------------------
//
//	Revolver
//
// --------------------------------------------------------------------------

ACTOR TE_Revolver : BaseWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 6
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "RevolverBullets"
	Weapon.AmmoType2 "TE_RevolverAmmo"
	Weapon.SelectionOrder 5000
	Weapon.Kickback 200
	-WEAPON.CHEATNOTWEAPON
	Weapon.SisterWeapon "DualRevolver"
	Inventory.PickupSound "revolver/draw"
	Inventory.Pickupmessage "You got the Revolver!"
	Obituary "%o got shot into pieces by %k's revolver."
	tag "Revolver"
	Scale 0.7
	States
	{
 	Spawn:
		RVIC A -1
		Stop
	
	Select:
		TNT1 A 0 A_JumpIfInventory("IsPlayingAsPurist",1,"PuristGun")
		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1001,2)==0,"PuristGun")
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_Takeinventory("StartDualWield",1)
		TNT1 A 0 A_Takeinventory("Unloading",1)
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_TakeInventory("TossGrenade",1)
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("SwitchFlashlight",1)
		TNT1 A 0 A_Takeinventory("Taunting",1)
		TNT1 A 0 A_Takeinventory("IdleCounter",200)
		TNT1 A 6
		TNT1 A 0 A_Raise
		Wait
		
	Deselect:
		TNT1 A 0 A_PlaySound("weapons/changing")
		REVF A 1
		REVD ABCD 1
		TNT1 A 1
		TNT1 A 0 A_Lower
		Wait
			
	Ready:
		TNT1 A 0 A_JumpIfInventory("GoFatality",1,"Steady")
		TNT1 A 0 A_PlaySound("revolver/draw",5)
	Ready1:
		REVD DCBA 1
	Ready2:
		TNT1 A 0 //A_GunFlash
	Ready3:
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"TauntL")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"WeapSpecial")
		TNT1 A 0 A_JumpIfInventory("SwitchFlashlight",1,"WeapSpecial")
		TNT1 A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		TNT1 A 0 A_JumpIfInventory("IdleCounter",200,"PlayerIsIdle")
		REVF A 1 A_WeaponReady
		Loop
		
// --------------------------------------------------------------------------
//
//	Fire
//
//		With each fire the weapon cycles to the next "RevolverCylinderPos"
//		by adding one token to the player. If the player has 7 tokens we go back
//		to 1, since there's only 6 possible positions in the chamber.
//		Then check if the player has the "RevolverCylinderSlot"-token for that slot,
//		and if that's the case - remove the token so that we know in the future that
//		that position has been fired. Then continue to fire as normal.
//
//		When the player spins the cylinder we get a new starting position for
//		"RevolverCylinderPos", wo that we can play russian roulette.
//		When we reload the weapon we gain all tokens back.
//
// --------------------------------------------------------------------------

	FireBullet:
		TNT1 A 0 A_Jump(25,5) //10% chance to do a critical hit.
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff1B")
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff1B")
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff1A")
		TNT1 A 0 A_FireCustomMissile("RWP",0,0,0,0) //RevolverWallPenetrator
		Stop
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff2B")
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff2B")
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff2A")
		TNT1 A 0 A_FireCustomMissile("RWP",0,0,0,0) //RevolverWallPenetrator
		Stop

	Fire:
		TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",1,2)
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,"Reload")
		Goto DryFire
		
		//Bring forth next cylinder slot
		TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_GiveInventory("RevolverCylinderPos",1)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",7,2)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_TakeInventory("RevolverCylinderPos",6)
		
		//Check if selected slot has a bullet
		//Slot 1
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",2,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot1",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot1",1)
		TNT1 A 0 A_Jump(256,19)
		//Slot 2
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",3,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot2",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot2",1)
		TNT1 A 0 A_Jump(256,15)
		//Slot 3
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",4,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot3",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot3",1)
		TNT1 A 0 A_Jump(256,11)
		//Slot 4
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",5,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot4",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot4",1)
		TNT1 A 0 A_Jump(256,7)
		//Slot 5
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",6,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot5",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot5",1)
		TNT1 A 0 A_Jump(256,3)
		//Slot 6
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot6",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot6",1)
		
		//Slot has a bullet. Fire!
		TNT1 A 0 A_PlaySound("revolver/fire1",1)
		TNT1 A 0 A_PlaySound("revolver/fire2",5,0.7)
		REVF BC 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_ZoomFactor(0.80)
		TNT1 A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		TNT1 A 0 A_Jump(128,3)
		REVF D 1 BRIGHT A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Jump(256,2)
		REVF E 1 BRIGHT A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 AAAA 0 A_FireCustomMissile("ShotgunParticles",frandom(-10,10),0,-1,-8,0,frandom(-10,10))
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		TNT1 AA 0 A_FireCustomMissile("GunFireSmoke",0,0,0,0,0,0)
		TNT1 A 0 A_FireCustomMissile("Tracer",frandom(-2,2),0,-1,0)
		TNT1 A 0 A_FireCustomMissile("ShakeYourAssDouble",0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("PlayerMuzzle2",30,5,27)
		TNT1 A 0 A_AlertMonsters
		
		TNT1 A 0 A_SetAngle(frandom(0.8,-0.8) + angle)
		TNT1 A 0 A_SetPitch(frandom(0.8,-0.8) + pitch)
		TNT1 A 0 A_GunFlash("FireBullet")
		
		TNT1 A 0 A_Takeinventory("TE_RevolverAmmo",1)
		TNT1 A 0 A_Recoil(0.3)
		TNT1 A 0 A_SetAngle(frandom(2,-2) + angle)
		TNT1 A 0 A_setpitch(pitch - 8.0)
		TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_ZoomFactor(1.00)
		REVF GGFF 1 A_setpitch(pitch + 1.2)
		TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVF A 7 A_WeaponReady
		Goto Ready2

	AltFire:
		TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",1,2)
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,"Reload")
		Goto DryFire
		
		//Bring forth next cylinder slot
		REVF HIJKL 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Jump(256,6)
		
	AltHold:
		TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",1,2)
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,"Reload")
		Goto DryFire
		REVF VKL 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_GiveInventory("RevolverCylinderPos",1)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",7,2)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_TakeInventory("RevolverCylinderPos",6)
		
		//Check if selected slot has a bullet
		//Slot 1
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",2,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot1",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot1",1)
		TNT1 A 0 A_Jump(256,19)
		//Slot 2
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",3,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot2",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot2",1)
		TNT1 A 0 A_Jump(256,15)
		//Slot 3
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",4,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot3",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot3",1)
		TNT1 A 0 A_Jump(256,11)
		//Slot 4
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",5,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot4",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot4",1)
		TNT1 A 0 A_Jump(256,7)
		//Slot 5
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",6,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot5",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot5",1)
		TNT1 A 0 A_Jump(256,3)
		//Slot 6
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot6",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot6",1)
		
		//Slot has a bullet. Fire!
		TNT1 A 0 A_PlaySound("revolver/fire1",1)
		TNT1 A 0 A_PlaySound("revolver/fire2",5,0.7)
		TNT1 A 0 A_ZoomFactor(0.80)
		TNT1 A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		TNT1 A 0 A_Jump(128,3)
		REVF M 1 BRIGHT A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Jump(256,2)
		REVF N 1 BRIGHT A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 AAAA 0 A_FireCustomMissile("ShotgunParticles",frandom(-10,10),0,-1,-8,0,frandom(-10,10))
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		TNT1 AA 0 A_FireCustomMissile("GunFireSmoke",0,0,0,0,0,0)
		TNT1 A 0 A_FireCustomMissile("Tracer",frandom(-2,2),0,-1,0)
		TNT1 A 0 A_FireCustomMissile("ShakeYourAssDouble",0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("PlayerMuzzle2",30,5,27)
		TNT1 A 0 A_AlertMonsters
		
		TNT1 A 0 A_SetAngle(frandom(1.6,-1.6) + angle)
		TNT1 A 0 A_SetPitch(frandom(1.6,-1.6) + pitch)
		TNT1 A 0 A_GunFlash("FireBullet")

		TNT1 A 0 A_Takeinventory("TE_RevolverAmmo",1)
		TNT1 A 0 A_Recoil(0.3)
		TNT1 A 0 A_SetAngle(frandom(2,-2) + angle)
		TNT1 A 0 A_setpitch(pitch - 8.0)
		TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_ZoomFactor(1.00)
		REVF OPQ 1 A_SetPitch(pitch + 1.3)
		TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVF R 1 A_Refire
		REVF WXYZ 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVF A 3 A_WeaponReady
		Goto Ready2


// --------------------------------------------------------------------------
//
//	Reload
//
// --------------------------------------------------------------------------
	
	Reload:
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",6,"Ready2")
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,1)
		Goto Ready2
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,"ReloadLoop")
		REVF A 5 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVR A 2
		TNT1 A 0 A_PlaySound("revolver/reload")
		REVR BC 2
		REVR DEF 1
		REVR GGG 2
		
		//How many cases should we spawn?
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot1",1,2)
		TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot2",1,2)
		TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot3",1,2)
		TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot4",1,2)
		TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot5",1,2)
		TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot6",1,2)
		TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
		
		REVR HIJKLMNOPQRSTUEDCBA 2
		REVF Z 2
				
	ReloadLoop:
		TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",6,5)
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,2)
		TNT1 A 0 A_Jump(256,3)
		TNT1 A 0 A_Giveinventory("TE_RevolverAmmo",1)
		TNT1 A 0 A_Takeinventory("RevolverBullets",1)
		Goto ReloadLoop
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot1",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot2",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot3",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot4",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot5",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot6",1)
		TNT1 A 0 A_Refire
		Goto Ready2
		
// --------------------------------------------------------------------------
//
//	Misc.
//
// --------------------------------------------------------------------------

	DualWield:
		TNT1 A 0 A_Takeinventory("StartDualWield",1)
		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1028)==0,"NoDualWield")
		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1028)==2,"Ready2")
		TNT1 A 0 A_JumpIfInventory("TE_Revolvers",2,2)
		TNT1 A 0 A_Print("You must have two revolvers to dual wield.")
		Goto Ready2
		REVD ABCD 1
		TNT1 A 6
		TNT1 A 0 A_Takeinventory("StartDualWield",1)
		TNT1 A 0 A_Giveinventory("PowerSphere2",1)
		Goto Ready

	NoDualWield:
		TNT1 A 0 A_Print("Dual wielding is disabled.")
		Goto Ready2

	DryFire:
		REVF BC 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVF A 1 A_PlaySound("weapons/empty2")
		Goto Ready2

	WeapSpecial:
		REVF A 1
		REVR ABC 1 
		REVR DE 1
	SpinMoar:
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("SwitchFlashlight",1)
		TNT1 A 0 A_PlaySound("revolver/spin")
		REVR UTSR 2
		REVS ABCDEFDE 1
		REVS CD 2
		REVS E 3
		TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"SpinMoar")
		TNT1 A 0 A_JumpIfInventory("SwitchFlashlight",1,"SpinMoar")
		REVR EDCBA 2
		TNT1 A 0 A_GiveInventory("RevolverCylinderPos",random(1,6))
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",7,2)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_TakeInventory("RevolverCylinderPos",6)
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("SwitchFlashlight",1)
		Goto Ready2

	DryFireAlt:
		TNT1 A 0 A_PlaySound("weapons/empty2")
		REVF STUR 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire
		REVF WXYZ 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVF A 3 A_WeaponReady
		Goto Ready2
	
	PuristGun:
		TNT1 A 0 A_TakeInventory("Revolver",1)
		Goto Deselect
		
// --------------------------------------------------------------------------
//
//	End stuff
//
// --------------------------------------------------------------------------

	TauntFlash:
		REVD ABCD 1
		TNT1 A 35
		REVD DCBA 1
		REVF A 1
		Stop

	KickFlash:
		REVK ABCD 1
		REVK D 8
		REVK DCBA 1
		REVF A 1
		Stop

	AirKickFlash:
		REVK ABCD 1
		REVK D 10
		REVK DCBA 1
		REVF A 1
		Stop

	SlideKickStartFlash:
		REVK ABCD 1
		REVK D 17
		Stop

	SlideKickEndFlash:
		REVK DDCBA 2
		REVF A 1
		Stop

	GrenadeFlash:
		REVD ABCD 1
		Stop
	}
}

ACTOR RevolverCylinderPos : Inventory { Inventory.MaxAmount 12 }
ACTOR RevolverCylinderSlot1 : Ammo { Inventory.MaxAmount 1 }
ACTOR RevolverCylinderSlot2 : Ammo { Inventory.MaxAmount 1 }
ACTOR RevolverCylinderSlot3 : Ammo { Inventory.MaxAmount 1 }
ACTOR RevolverCylinderSlot4 : Ammo { Inventory.MaxAmount 1 }
ACTOR RevolverCylinderSlot5 : Ammo { Inventory.MaxAmount 1 }
ACTOR RevolverCylinderSlot6 : Ammo { Inventory.MaxAmount 1 }

ACTOR TE_RevolverAmmo : Ammo
{
	+INVENTORY.IGNORESKILL
	Inventory.Amount 0
	Inventory.MaxAmount 6
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 6
   	Inventory.Icon "RVICA0"
}

Actor RevolverPuff1A
{
	Renderstyle Translucent
	Alpha 0.4
	Scale 1.5
	Radius 0
	Height 0
	Gravity 0.01
	DamageType Blast
	Decal "RevolverDecal"
	+NOBLOCKMAP
	+NOGRAVITY
	+NOEXTREMEDEATH
	+FORCEXYBILLBOARD
	+DONTSPLASH
	-EXPLODEONWATER
	states
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("RevolverRicoChet",0,0,-5,0,0,0,0,SXF_NOCHECKPOSITION,0)
	Melee:
		TNT1 A 0
		stop
	}
}

Actor RevolverPuff1B : RevolverPuff1A
{
	Decal "None"
	states
	{
	Spawn:
		TNT1 A 0
	Melee:
		TNT1 A 0
		stop
	}
}

Actor RevolverPuff2A : RevolverPuff1A
{
	DamageType SSG
	Decal "RevolverDecal"
}

Actor RevolverPuff2B : RevolverPuff1A
{
	DamageType SSG
	Decal "None"
	states
	{
	Spawn:
		TNT1 A 0
	Melee:
		TNT1 A 0
		stop
	}
}


// --------------------------------------------------------------------------
//
//	Revolver Wall Penetrator
//		Heavily edited original code by Sergeant Mark IV
//
// --------------------------------------------------------------------------

ACTOR RWP : FastProjectile 														//This is the first wall-penetrator-projectile.
{
	Projectile
	+FORCEXYBILLBOARD
	+DONTSPLASH
	damage 0
	radius 2
	height 2
	speed 900
	States
	{
	Spawn:
		TNT1 A 0
	Fly:
		TNT1 A 1																//It will fly until it hits a wall...
		Loop
	Death:
		TNT1 A 0 A_CustomMissile("RWP2",0,0,0,0,0)								//...and then fires the second projectile...
		TNT1 A 1																//...and dies.
	Crash:
	Xdeath:
		TNT1 A 0
		Stop
	}
}

ACTOR RWP2
{
	PROJECTILE
	+Missile
	+NOCLIP																		//The second projectile has noclip,so that it can fly through walls.
	Damage 1
	Radius 2
	Height 2
	Speed 1																		//It have a speed of 1 because the projectile actualy moves instantly when it spawns...
	Decal "BulletDecalNew1"
	States
	{
	Spawn:
		TNT1 A 0																//...and it's aimed directly at the player,so we have to invert it's speed to make it go the right direction...
		TNT1 A 0 A_ChangeVelocity(VelX * -40,VelY * -40,VelZ * -40,CVF_REPLACE) //...by multiplying by a negative number.
		TNT1 A 1 																//One tic of flight. The projectile will move a total of X units. Where X is the multiplier on the above line.
		TNT1 A 0 A_CheckCeiling("Bummer")										//If it ends in a ceiling...
		TNT1 A 0 A_CheckFloor("Bummer")											//...or in a floor,it stops here.
		TNT1 A 0 A_CustomMissile("RWP3",0,0,0,0,0)								//Now fire the third projectile.
		TNT1 A 0 A_ChangeVelocity(VelX * -0.8,VelY * -0.8,VelZ * -0.8,CVF_REPLACE) //Change direction again...
		TNT1 A 0 A_ChangeFlag("NOCLIP",FALSE)									//...and make it able to hit walls...
		TNT1 A 1																//... and have the projectile move one tic,so that we get an exit hole on the wall.
		Stop
	Bummer:
		TNT1 A 0
		Stop
	Death:
	XDeath:
		TNT1 A 0
		Stop
	}
}

ACTOR RWP3 : FastProjectile														//This is the actual projectile that emerges from the other side of the wall.
{
	Projectile
	+FORCEXYBILLBOARD
	+DONTSPLASH
	damage 20																	//It has damage,it can kill stuff!
	radius 2
	height 2
	speed 1																		//It have a speed of 1 because the projectile actualy moves instantly when it spawns...
	renderstyle ADD
	Decal "BulletDecalNew1"
	alpha 0.9
	scale .3
	States
	{
	Spawn:
		TNT1 A 0																//...and it's aimed directly at the player,so we have to invert it's speed to make it go the right direction...
		TNT1 A 0 A_ChangeVelocity(VelX * -200,VelY * -200,(VelZ * -200)-10,CVF_REPLACE) //...by multiplying by a negative number.
	Fly:
		TRAC A 1 BRIGHT															//Flyg fula fluga flyg.
		Loop
	Death:
		TNT1 A 0 A_SpawnItemEx("RicoChet",0,0,-5,0,0,0,0,SXF_NOCHECKPOSITION,0)
		Stop
	}
}