// --------------------------------------------------------------------------
//
// Breachcharge (Weapon)
//
// --------------------------------------------------------------------------

ACTOR "Breachcharge" : CSDMOWeapon //5010
{
//+CHEATNOTWEAPON
+AMMO_OPTIONAL

	Weapon.SelectionOrder 1900
  weapon.ammotype "BreachchargeClip"
  weapon.ammouse 1
  weapon.ammogive 0
//  weapon.ammotype2 "BreachchargeClip"
//  weapon.ammouse2 0
//  weapon.ammogive2 0 //30
	obituary "%k killed %o with Breachcharge."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Picked up a Breach charge"
	Tag "Breach charge"
	Weapon.UpSound "Breachcharge/Ready"
	//AttackSound "Breachcharge/Fire"
	Scale 0.16

	States
	{

	NoShot:
	TNT1 A 0 A_Print("You don't have enough charges.", 3)
		W48C A 1 A_WeaponReady
		Goto Ready

	Ready:
		W48C A 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"Alt_Jump")
		Loop



	Deselect:
TNT1 A 1 A_TakeInventory("Grenade_BlockMemo",1)
	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 2, 0, 0)
    TNT1 A 0
	Goto DeselectLoop

	Select:
	TNT1 A 1 A_Raise
	TNT1 AA 0 A_Raise
	TNT1 A 0 ACS_ExecuteAlways(798, 0, 220, 0, 0)//Weapon Weight
	W48A B 1 A_TakeInventory("CrosshairType",2)

	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 1, 0, 0)
    TNT1 A 0 A_JumpIfInventory("RAT_Trigger",1,"RAT_TriggerSelect")

		W48A CDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

	Rat_TriggerSelect:
    TNT1 A 0 A_TakeInventory("Rat_Trigger",1)

		W48A CDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

	Fire:
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotFire")
	W48C A 0 A_JumpIfNoAmmo("NoShot")
		
		W48D A 0 A_GunFlash("Flash")
		W48D ABCDEFGHIJKLMNO 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_Refire
		Goto Ready


  Altfire:
	W48C A 0 A_JumpIfNoAmmo("Ready")
Alt_Jump:		
		W48E A 0 A_GunFlash("Flash_Explode")
		W48E ABCDEFGHIJKLMNOP 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_Refire
		Goto Ready


	BotFire:
		
		W48D A 0 A_GunFlash("Flash")
		W48D ABCDEFGHIJKLMNO 1 A_WeaponReady(WRF_NOFIRE)
		W48E A 0 A_GunFlash("Flash_Explode")
		W48E ABCDEFGHIJKLMNOP 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_Refire
		Goto Ready



	Flash:

		TNT1 A 0 A_PlaySound ("Breachcharge/FIRE")
		TNT1 A 0 
		TNT1 A 0 
		TNT1 A 2 A_FireCustomMissile(BreachchargePROJECTILE,0,1,0,3,0,4)
		Goto LightDone


	Flash_Explode:
//		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound ("Breachcharge/ALTFIRE")
		TNT1 A 0 
        TNT1 A 0 ACS_NamedExecuteWithResult("CSDMO_BreachchargeDetonate")
		TNT1 A 0 
		TNT1 A 2 
		Goto LightDone


 	Spawn:
		W48Z A -1
		Stop
	}
}





ACTOR BreachchargeProjectile
{
	Game Doom
	SpawnID 216
	Radius 8
	Height 8

	Damage 0
	Projectile
    BounceType "Hexen"
	-NOGRAVITY
	+RANDOMIZE
	+DEHEXPLOSION
+USEBOUNCESTATE
  +CANBOUNCEWATER
  +BOUNCEONACTORS
+THRUSPECIES
	//+GRENADETRAIL
//	+doombounce
	//BounceType "Doom"
//	Gravity 0.25
	SeeSound "dsempty"
	DeathSound "HEGRENADE/EXPLODE"
	//BounceSound "weapons/grbnce"
	Obituary "%k killed %o with Breachcharge."
	DamageType Grenade

scale 0.07

   ExplosionRadius 192
   ExplosionDamage 256
  Speed 22

	BounceFactor 0.15
WallBounceFactor 0.25
//BounceCount 2

//  BounceFactor 0.7
  ReactionTime 70


	States
	{
	Spawn:
        TNT1 A 0 NoDelay ACS_NamedExecuteWithResult("CSDMO_BreachchargeFired")
	Idle:
		W48X AAABBBCCCDDDEEEFFFGGGHHH 1 Bright //A_Countdown
		Loop

IdleSound:
tnt1 a 0 A_PlaySound("breachcharge/Stump")
Goto Idle


bounce.ceiling:
bounce.wall:
tnt1 a 0 A_PlaySound("breachcharge/Stump")
Goto Idle
bounce.floor:
TNT1 A 0 A_JumpIf(velz > 1, "IdleSound")
Goto BounceDed

BounceDed:
XDeath:
Crash:
W48X I 1 BRIGHT A_Stop//CountDown
Loop


	Death:
		TNT1 A 0 A_ChangeFlag("NOINTERACTION",1)
	TNT1 A 0 A_NoGravity
MISL B 0 A_AlertMonsters
    TNT1 B 0 A_SpawnItemEx("NewExplosionMedium_C4",0,0,0,0,0,0,0,32)//A_SpawnItemEx("NewExplosionMediumBig",0,0,0,0,0,0,0,32)
		TNT1 B 1 Bright A_Explode
		TNT1 C 0 Bright A_PlaySound("HEGRENADE/EXPLODE")
		TNT1 D 0 Bright A_PlaySound("explode/Distant", 7)
		Stop
	Grenade:
		MISL A 1000 A_Die
		Wait
	Detonate:
	TNT1 A 0 A_NoGravity
MISL B 0 A_AlertMonsters
    TNT1 B 0 A_SpawnItemEx("NewExplosionMedium_C4",0,0,0,0,0,0,0,32)//A_SpawnItemEx("NewExplosionMediumBig",0,0,0,0,0,0,0,32)
		TNT1 A 0 A_PlaySound("explode/Distant", 7)
		TNT1 B 1 A_Scream
PLAY A 0 ACS_ExecuteAlways(807,0,0,0,0)
		TNT1 C 0 A_Detonate
		TNT1 D 0
		Stop
	Mushroom:
		MISL B 0 A_Mushroom
		Goto Death+1
	}
}

