//Generic effects used for multiple weapons



ACTOR DVPuff : BulletPuff
{
	+NOBLOCKMAP
	+NOGRAVITY
	+ALLOWPARTICLES
	+RANDOMIZE
	+THRUSPECIES
	+MTHRUSPECIES
	+PUFFONACTORS
	+BRIGHT
	+NOEXTREMEDEATH
	+HITTRACER
	species "Player"
	decal "bulletchip"
	RenderStyle Add
	Alpha 0.50
	VSpeed 0
	scale 0.20
	Mass 5
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 1		
	XDeath:
		TNT1 A 1
		TNT1 A 0 A_PlaySound ("Deriver/PuffHit",CHAN_VOICE,0.5,0,1.5)	
		TNT1 A 0 A_SetScale (0.90,0.90)
		MNSP ABCD 1
		stop
	Crash:
		BPK1 A 1 Bright
		BPK1 A 1
		TNT1 A 0 A_PlaySound ("Deriver/PuffMiss",CHAN_VOICE,0.5,0,1.5)	
		TNT1 AA 0 A_SpawnItemEx("SmasherSmoke",5,0,0,frandom(-0.5,0.5),frandom(-1,1),frandom(0.5,1.5),0,SXF_NOCHECKPOSITION)
		TNT1 AAAAA 0 A_SpawnItemEx ("CABulletSpark",5,0,0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,0,SXF_NOCHECKPOSITION,160)		
		BPK1 A 1 A_SetScale (scalex * frandom(1.20,1.40),scaley * frandom(1.20,1.40))
		BPK1 A 1 A_SetScale (scalex * frandom(0.70,0.80),scaley * frandom(0.70,0.80))
		BPK1 A 1 A_SetScale (scalex * frandom(0.20,0.40),scaley * frandom(0.20,0.40))
		Stop
	}
}


ACTOR DVSGPuff : DVPuff
{
	ProjectileKickBack 300
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 1		
	XDeath:
		TNT1 A 1
		TNT1 A 0 A_PlaySound ("Deriver/PuffHit",CHAN_VOICE,0.25,0,1.5)	
		TNT1 A 0 A_SetScale (0.90,0.90)
		MNSP ABCD 1
		stop
	Crash:
		BPK1 A 1 Bright
		BPK1 A 1
		TNT1 A 0 A_PlaySound ("Deriver/PuffMiss",CHAN_VOICE,0.25,0,1.9)	
		TNT1 AA 0 A_SpawnItemEx("SmasherSmoke",5,0,0,frandom(-0.5,0.5),frandom(-1,1),frandom(0.5,1.5),0,SXF_NOCHECKPOSITION)
		TNT1 AAAAA 0 A_SpawnItemEx ("CABulletSpark",5,0,0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,0,SXF_NOCHECKPOSITION,160)		
		BPK1 A 1 A_SetScale (scalex * frandom(1.20,1.40),scaley * frandom(1.20,1.40))
		BPK1 A 1 A_SetScale (scalex * frandom(0.70,0.80),scaley * frandom(0.70,0.80))
		BPK1 A 1 A_SetScale (scalex * frandom(0.20,0.40),scaley * frandom(0.20,0.40))
		Stop
	}
}

ACTOR DVSGPuff2 : DVPuff
{
	ProjectileKickBack 700
	States
	{
	XDeath:
		TNT1 A 1
		TNT1 A 0 A_PlaySound ("Deriver/PuffHit",CHAN_VOICE,0.25,0,1.5)	
		TNT1 A 0 A_SetScale (0.90,0.90)
		TNT1 A 0 A_GiveInventory ("DeriverBoost",1,AAPTR_TRACER)
		MNSP ABCD 1
		stop
	}
}


ACTOR DeriverBoost : CustomInventory
{
	+AUTOACTIVATE
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		Stop
	Use:
		TNT1 A 0
		TNT1 A 0 thrustthingz (0,20,0,0)
		TNT1 A 1 
		Stop
	}
}


ACTOR CABulletSpark : Fastprojectile
{
	radius 3
	height 6
	speed 10
	scale 0.25
	projectile
	+FLOORCLIP
	+DONTSPLASH
	+THRUACTORS
	+NOTELEPORT
	+CLIENTSIDEONLY
	+bright
	+HEXENBOUNCE
	Gravity 1
	bouncecount 3
	Renderstyle Add
	alpha 0.80
	missiletype "CABulletSparkTrail"
	Missileheight 9
	States
	{
	spawn:
		TNT1 A 0 
		TNT1 A 1
		TNT1 A 0 A_JumpIf(floorz == z, "SparkJump")
		GoTo Flight
	SparkJump:
		TNT1 A 1 ThrustThingZ (0,Random(20,46),0,0)
	Flight:
		TNT1 A 1 ThrustThingZ (0,Random(5,10),1,1)
		TNT1 A 1 ThrustThingZ (0,Random(5,10),1,1)
		TNT1 A 1 ThrustThingZ (0,Random(5,10),1,1)
		TNT1 A 1 ThrustThingZ (0,Random(5,10),1,1)
		goto death
	Death:
		TNT1 A 1
		stop
	}
}

actor CABulletSparkTrail
{
	+nointeraction
	+clientsideonly
	scale 0.25
	renderstyle add
	alpha 0.90
	states
	{
	spawn:
		PUFF A 1
		goto death
	death:
		PUFF A 1
		TNT1 A 0 A_FadeOut (0.20)
		loop
	}
}



//Buran magazine

ACTOR BuranMagDropper
{
	Speed 13
	PROJECTILE
	+NOCLIP
	States
	{
	Spawn:
		TNT1 A 0 
		TNT1 A 0 A_SpawnItemEx ("BuranMagDrop",9,0,0,0,random(-6,-12),random(3,5),0,SXF_NOCHECKPOSITION)
		TNT1 A 1
		//TNT1 AA 0 A_CustomMissile("BuranMagDrop",0,0,random(-100,-80),CMF_AIMDIRECTION,random(-15,15))
		Stop
	}
}


ACTOR BuranMagDrop
{
	Radius 3
	Height 5
	Speed 0
	Scale 0.80
	PROJECTILE
	-NOGRAVITY
	+BOUNCEONACTORS
	+Bright
	Gravity 0.75
	BounceType Doom
	BounceCount 4
	BounceFactor 0.5
	+clientsideonly
	States
	{
	Spawn:
		CLP1 A 0
		CLP1 ABCDEFGH 1 A_JumpIf(floorz == z, "clipbounce")
		Loop
	clipbounce:
		TNT1 A 0 A_PlaySound ("Buran/MagClatter",0,0.80,0,1.50)
		CLP1 A 1 ThrustThing (random(1,359),1,0,0)
		goto spawn
	Death:
		TNT1 A 0 A_Jump (256, "dead1", "dead2")
		loop
	Dead1:
		TNT1 A 0 A_PlaySound ("Buran/MagClatter",0,0.80,0,1.50)
		CLP1 I Random (1500,2000)
		CLP1 I 1 A_FadeOut (0.01)
		wait
	Dead2:
		TNT1 A 0 A_PlaySound ("Buran/MagClatter",0,0.80,0,1.50)
		CLP1 J Random (1500,2000)
		CLP1 J 1 A_FadeOut (0.01)
		wait
	}
}


//=============================================================================================
//=============================================================================================
//SHELL CASINGS
//=============================================================================================
//=============================================================================================


ACTOR DeriverShellcasingspawner //Shamelessly stolen from probably one of Weasel's mods, yoink. (Then taken by me, double yoink)
{
	Speed 13
	PROJECTILE
	+NOCLIP
	States
	{
	Spawn:
		TNT1 AA 0 A_CustomMissile("DeriverShellCasing",0,0,random(-100,-80),CMF_AIMDIRECTION,random(-15,15))
		Stop
	}
}

ACTOR DeriverShellCasing
{
	Radius 2
	Height 4
	Speed 8
	Scale 0.2
	PROJECTILE
	-NOGRAVITY
	+BOUNCEONACTORS
	+DONTSPLASH
	+Bright
	+USEBOUNCESTATE
	Gravity 0.75
	BounceType Doom
	BounceCount 6
	BounceFactor 0.6  
	+clientsideonly
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ThrustThingz (0,random(10,15),0,1)
		CAS1 ABCDEFGH 1 
		Goto rollingloop
	RollingLoop:
		CAS1 ABCDEFGH 1 
		Loop
	Bounce:
		CAS1 # 1 A_PlaySound ("DShotGun/Shell",0,1,0,1.6)
		GoTo RollingLoop
	Death:
		TNT1 A 0 A_Jump (256, "dead1","dead2")
		loop
	dead1:
		TNT1 A 0 A_PlaySound ("DShotGun/Shell",0,1,0,1.6)
		CAS1 I Random (900,1500)
		CAS1 I 1 A_FadeOut (0.01)
		wait
 	dead2:
		TNT1 A 0 A_PlaySound ("DShotGun/Shell",0,1,0,1.6)
		CAS1 J Random (900,1500)
		CAS1 J 1 A_FadeOut (0.01)
		wait
	}
}


//=============================================================================================
//=============================================================================================
//SMOKE STUFF
//=============================================================================================
//=============================================================================================


ACTOR SmasherSmokeSpawner
{
	projectile
	RenderStyle Translucent
	speed 20
	-SOLID
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	Spawn:
        TNT1 A 0
        TNT1 A 1 a_stop
        TNT1 AA 0 A_SpawnItemEx("SmasherSmoke",frandom(-0.1,0.1),frandom(-0.1,0.1),frandom(-1.5,-1.5),frandom(0.5,5),frandom(-0.5,0.5),frandom(-0.5,0.5),0,32)
        TNT1 A 1 A_SpawnItemEx("SmasherSmoke",frandom(-0.1,0.1),frandom(-0.1,0.1),frandom(-1.5,-1.5),frandom(0.5,5),frandom(-0.5,0.5),frandom(-0.5,0.5),0,32)
        TNT1 AA 0 A_SpawnItemEx("SmasherSmoke",frandom(-0.1,0.1),frandom(-0.1,0.1),frandom(-1.5,-1.5),frandom(0.5,5),frandom(-0.5,0.5),frandom(-0.5,0.5),0,32)
        TNT1 A 1 A_SpawnItemEx("SmasherSmoke",frandom(-0.1,0.1),frandom(-0.1,0.1),frandom(-1.5,-1.5),frandom(0.5,5),frandom(-0.5,0.5),frandom(-0.5,0.5),0,32)
		Stop
	}
}

actor SmasherSmoke
{
    Radius 1
    Height 1
	Scale 0.10
	renderstyle add
	Alpha 0.80
    Projectile
	+FORCEXYBILLBOARD
	+clientsideonly
    +NOCLIP
    States
    {
   Spawn:
      TNT1 A 2
      SMOK ABCDEFGHIJKLMNOPQ 2 A_FadeOut(0.1)
      Stop
    }
}



actor MiniSmoke
{
    Radius 1
    Height 1
	Scale 0.05
	renderstyle add
	Alpha 0.80
    Projectile
	+FORCEXYBILLBOARD
	+clientsideonly
    +NOCLIP
    States
    {
   Spawn:
      TNT1 A 2
      SMOK ABCDEFGHIJKLMNOPQ 2 A_FadeOut(0.1)
      Stop
    }
}



actor TridentSmoke : SmasherSmoke
{
	Scale 0.10
	renderstyle Add
	Alpha 0.96
    States
    {
   Spawn:
      TNT1 A 2
      SMOK ABCDEFGHIJKLMNOPQ 2 A_FadeOut(0.07)
      Stop
    }
}


actor TridentRingParticle
{
    +NOINTERACTION
    +CLIENTSIDEONLY
    +FORCEXYBILLBOARD

    RenderStyle Add
    Alpha 0.255
    Scale 0.15
    Radius 0
    Height 0

    States
    {
      Spawn:
        SMOK A 1 bright A_FadeOut(0.05575)
        loop
    }
}

//=============================================================================================
//=============================================================================================
//FLARES AND PARTICLES
//=============================================================================================
//=============================================================================================

actor DeriverFlare
{
	+CLIENTSIDEONLY

	Projectile
	-NOGRAVITY
	+THRUACTORS
	+FORCEXYBILLBOARD
	+PAINLESS
	+NOTRIGGER
	Gravity 0.67
	Damage 0

	Radius 3
	Height 3

	BounceType Doom
	BounceFactor 0.25
	WallBounceFactor 1

	Scale 0.075
	RenderStyle Add

	ReactionTime 105

	States
    {
	Spawn:
		DVLZ A 0 bright A_SpawnItemEx("MiniSmoke", 0,0,0, frandom(-1, 1), 0, frandom(-1, 1), random(0, 360))
		DVLZ A 1 bright A_Countdown
		loop


	Death:
		TNT1 A 0
		TNT1 A 1
		stop
	}
}



//Harmless bullet puff actor to activate switches for projectile
//only weapons

actor DeriverFlickPuff : bulletpuff
{
	renderstyle "normal"
	+FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+bloodlessimpact
	+PUFFONACTORS
	-ALLOWPARTICLES
	states
	{
	spawn:
		TNT1 A 0
		TNT1 A 1
		stop
	}
}