//	 TAURUS SA22-HC PERSONAL AUTOCANNON 
////////////////////

Actor Taurus_FirstShotDone : Inventory { Inventory.MaxAmount 1 }

actor tauruscannon : weapon replaces RocketLauncher{
	Tag "Taurus AutoCannon"

	weapon.selectionorder 150
	inventory.pickupsound "weapons/tp_fullcycle"
	inventory.pickupmessage "Taurus SA22M5 Personal AutoCannon"
	scale 0.32
	weapon.ammotype1 "cannonmag"
	weapon.ammotype2 "cannon_ammo"
	weapon.ammouse1 1
	weapon.ammogive2 15
	weapon.kickback 100
	Weapon.preferredSkin "CannonSkin"
	//weapon.bobstyle inverse
	//weapon.bobrangeX 0.4
	//weapon.bobrangeY 0.75
	//weapon.bobspeed 2.5
	+AMMO_OPTIONAL
	+NOALERT
	+WEAPON.NOAUTOAIM
   	states{
		spawn:
			TPCW A -1
			loop
		ready:
			NULL a 0 A_TakeInventory("Taurus_FirstShotDone", 1)
			TPCI A 1 A_WeaponReady
			NULL A 0 A_JumpIfInventory("TossGrenade", 1, "Grenade")
			NULL A 0 A_JumpIfInventory("ReloadingWeapon", 1, "Reload")
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "Sprint")
			loop
		
		/////
		Sprint:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SprStart")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto ready
		SprStart:
			TNT1 A 0 A_PlaySound("sfx/sprintstart",CHAN_AUTO)
			TNT1 A 0 ACS_ExecuteAlways(Player_ChangeSpeed,0,200,0,0)
			TNT1 A 0 A_SetBlend("49 99 0",0.4,15)
			TNT1 A 0 A_Recoil(-15)
			TPCS ABCDE 1
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "SprLoop1")
			goto SprEnd
		SprLoop1:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SL1")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto SprEnd
		SL1:
			TPCS E 1 Offset(-14,33)
			//TPCS E 1 Offset(-27,36)
			TPCS E 1 Offset(-34,39)
			TPCS E 1 Offset(-40,44)
			TPCS E 1 Offset(-43,47)
			TPCS E 1 Offset(-44,50)			
		
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "SprLoop2")
			goto SprEnd
		SprLoop2:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SL2")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto SprEnd
		SL2:
			TPCS E 1 Offset(-44,50)
			//TPCS E 1 Offset(-43,47)
			TPCS E 1 Offset(-40,44)
			TPCS E 1 Offset(-34,39)
			TPCS E 1 Offset(-27,36)
			TPCS E 1 Offset(-14,33)
			TNT1 A 0 A_TakeInventory("PlayerStamina", 4)
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "SprLoop3")
			goto SprEnd
		SprLoop3:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SL3")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto SprEnd
		SL3:
			TPCS E 1 Offset(14,33)
			//TPCS E 1 Offset(27,36)
			TPCS E 1 Offset(34,39)
			TPCS E 1 Offset(40,44)
			TPCS E 1 Offset(43,47)
			TPCS E 1 Offset(44,50)
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "SprLoop4")
			goto SprEnd
		SprLoop4:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, "SL4")
			TNT1 A 0 A_TakeInventory("SprintingPlayer",1)
			goto SprEnd
		SL4:
			TPCS E 1 Offset(44,50)
			//TPCS E 1 Offset(43,47)
			TPCS E 1 Offset(40,44)
			TPCS E 1 Offset(34,39)
			TPCS E 1 Offset(27,36)
			TPCS E 1 Offset(14,33)
			TNT1 A 0 A_TakeInventory("PlayerStamina", 4)
			TNT1 A 0 A_JumpIfInventory("SprintingPlayer", 1, "SprLoop1")
		SprEnd:
			TNT1 A 0 ACS_ExecuteAlways(Player_ChangeSpeed,0,100,0,0)
			TNT1 A 0 A_PlaySound("sfx/sprintend",CHAN_AUTO)
			TPCS EDCBA 1
			goto ready
		
		
		select:
			TNT1 A 0 //A_SetCrosshair(10)
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory",15,"GrenadeEnd")
			NULL A 10
			TPCU G 1 A_PlaySound("weapons/tp_select", CHAN_WEAPON)
			TPCU FEDCBA 1
			NULL A 0 A_GiveInventory("xhair_switch",1)
		selectloop:
			TPCI A 1 A_Raise
			goto selectloop
		
		deselect:
			NULL A 0 A_TakeInventory("xhair_switch",1)
			TPCU A 1 A_PlaySound("weapons/tp_deselect", CHAN_WEAPON)
			TPCU BCDEFG 1
			NULL A 2
		deselectloop:
			NULL A 1 A_Lower
			goto deselectloop
		
		fire:
			TNT1 A 0 A_JumpIfInventory("cannonmag", 1, 3)
			TPCI A 1 A_PlayWeaponSound("weapons/noammo")
			TPCI A 6
			goto Ready
			
			NULL A 0 A_Light1
			NULL A 0 A_AlertMonsters
			NULL A 0 A_PlaySound("weapons/tp_fire", CHAN_WEAPON)
			TPCF A 1 bright A_FireCustomMissile ("cslugshot", 0, 1, 5, 5 , 0, 0)
			//NULL A 0 ACS_ExecuteAlways(Weapon_Recoil,0,40,random(-20,20),0)
			
			TPCF B 1 bright
			TNT1 A 0 A_Light0
			TPBN A 1
			TNT1 A 0 A_JumpIfInventory("cannonmag", 1, 1)
			goto fire+14
			
			NULL A 0 A_GiveInventory("Taurus_FirstShotDone", 1)
			TPBN A 1 A_ReFire//("doublefire")
			goto fire+14
			
			TNT1 A 0
			TNT1 A 0 A_PlaySound("weapons/tp_halfcycle", CHAN_AUTO)			
			TNT1 A 0 A_JumpIfInventory("cannonmag", 1, 8)
			TPBH D 1
			TNT1 A 0 A_FireCustomMissile("cancasing_spawner",0,0,0,5,0)
			TPBH EF 1 //no shell
			TPBH GH 1
			TPCI A 1 
			Goto ready
			TPBH A 1
			TNT1 A 0 A_FireCustomMissile("cancasing_spawner",0,0,0,5,0)
			TPBH BC 1 //shell
			TPBH GH 1
			TPCI A 1 
			Goto ready
			
		Hold:
			TNT1 A 0 A_JumpIfInventory("Taurus_FirstShotDone", 1, "doublefire")
			Goto Fire
		doublefire: 
			TNT1 A 0 A_JumpIfInventory("cannonmag", 1, 14)
			TNT1 A 0 A_PlaySound("weapons/tp_fullcycle", CHAN_AUTO)
			TPBF D 1
			TNT1 A 0 A_FireCustomMissile("cancasing_spawner",0,0,0,5,0)
			TPBF EFG 1
			TNT1 A 0 A_FireCustomMissile("cancasing_spawner",0,0,0,4,0)
			TPBF KLMNO 1
			Goto ready
			
			TPBN CDE 1
			TPCI A 1 
			TNT1 A 0 A_Light1
			NULL A 0 A_AlertMonsters
			TNT1 A 0 A_PlaySound("weapons/tp_fire", CHAN_WEAPON)
			TPCF C 1 bright A_FireCustomMissile ("cslugshot", 0, 1, 5, 2 , 0, 0)
			//NULL A 0 ACS_ExecuteAlways(Weapon_Recoil,0,60,random(-30,30),0)
			goto doublefire+23 
		
			TPCF D 1 bright
			TNT1 A 0 A_Light0
			TPBN A 1 
			//TPBN B 1 
			NULL A 0 A_PlaySound("weapons/tp_fullcycle",CHAN_AUTO)
			TPBF D 1
			TNT1 A 0 A_FireCustomMissile("cancasing_spawner",0,0,0,5,0)
			TPBF EFG 1
			NULL A 0 A_JumpIfInventory("cannonmag", 1, 7)
			TNT1 A 0 A_FireCustomMissile("cancasing_spawner",0,0,0,4,0)
			TPBF KLMNO 1
			Goto ready
			TNT1 A 0 A_FireCustomMissile("cancasing_spawner",0,0,0,4,0)
			TPBF HIJNO 1
			Goto ready
			
		Reload:
			NULL A 0 A_JumpIfInventory("cannonmag", 30, 2)
			NULL A 0 A_JumpIfInventory("cannon_ammo", 1, 2)
			NULL A 0
			goto ready
					
			TPRS ABCDEFG 1
			TRCO A 4
			TRCO BC 1
			TRCO D 2 A_PlaySound("weapons/tp_clipout", CHAN_WEAPON)
			TRCO EEFFGHIJKL 1
			TRCO M 10
			TRCI ABCD 1
			TRCI EF 2
			TRCI GH 1
			TRCI I 1 A_PlaySound("weapons/tp_clipin", CHAN_WEAPON)		
			TRCI J 1
			TRCI K 4
			TRCI LMNOOPPQQRST 1
			TRCI U 1 A_PlaySound("weapons/tp_clipin2", CHAN_WEAPON)		
			NULL A 0 A_JumpIfInventory("cannonmag", 1, "Reload_FillClipB")
		
		Reload_FillClipA:	
			NULL A 0 A_TakeInventory("cannon_ammo",1)
			NULL A 0 A_GiveInventory("cannonmag",1)
			NULL A 0 A_JumpIfInventory("cannonmag",30,"ReloadFinish_Long")
			NULL A 0 A_JumpIfInventory("cannon_ammo",1,"Reload_FillClipA")			
		ReloadFinish_Long:
			TRCI U 5
			TRCE ABCDEFG 1
			TRLS ABCDEFGHIJKLMN 1 
			TRLS O 3 A_PlaySound("weapons/tp_bolt1",CHAN_WEAPON) 
			TRLS PQRS 1 
			TRLS TU 2
			TRLS V 4
			TNT1 A 0 A_PlaySound("weapons/tp_bolt2",CHAN_WEAPON) 
			TRLS UT 2
			TRLS WX 1
			NULL A 0 A_PlaySound("weapons/tp_fullcycle", CHAN_AUTO) 
			TRLE ABCD 1 
			
			NULL A 0 A_JumpIfInventory("cannonmag", 2, 4) 
			//1 shell left
			TRLE EGI 1
			goto RF_LongEnd
			
			//all shell left
			TRLE FHJ 1
		
		RF_LongEnd:
			TRLE KLMNO 1
			goto ready
			
		Reload_FillClipB:	
			NULL A 0 A_TakeInventory("cannon_ammo",1)
			NULL A 0 A_GiveInventory("cannonmag",1)
			NULL A 0 A_JumpIfInventory("cannonmag",30,"ReloadFinish_Quick")
			NULL A 0 A_JumpIfInventory("cannon_ammo",1,"Reload_FillClipB")
		ReloadFinish_Quick:
			TRCI U 5
			TRCE ABCDEFG 1
			TRQE ABCDEFG 1			
			goto ready
				
		Grenade:
			TNT1 A 0 A_JumpIfInventory("grenades", 1, 2)
			TNT1 A 0
			goto ready
			TPCG ABCDEFG 1 
			TNT1 A 0 A_GiveInventory("gtoss_weaponmemory", 15)
			TNT1 A 0 A_SelectWeapon("grenade_toss")
			goto deselectLoop
		GrenadeEnd:
			TNT1 A 0 A_TakeInventory("gtoss_weaponmemory",99)
			TPCG GFEDCBA 1
			goto selectLoop
				
		//////////////////////////////////////////////////////////////////		
		AltFire:
			TPCM C 1 A_Recoil(-7)
			NULL A 0 A_PlayWeaponSound("sfx/meleeswing")
			TPCM EGIK 1
			TPCM N 9 A_CustomPunch ((188+random(1,32)), 1 , 0 , "meleepuff",92)
			TPCM MLKJIHGFEDCBA 1
			goto ready
		
	}
		
}

actor cannonmag : Ammo{
	Inventory.MaxAmount 30
	Inventory.Icon "NULLA0"
	+INVENTORY.IGNORESKILL
}

actor cannoniscooling : Inventory {
	Inventory.Amount 1
	Inventory.MaxAmount 2
}

actor cann_autocool_sw : Inventory{
	Inventory.Amount 1
	Inventory.MaxAmount 2
}
//

actor cannon_casing {
	scale 0.3
	radius 2
	height 2
	speed 6
	mass 4
	bouncefactor 0.6
	PROJECTILE
	+DOOMBOUNCE
	+NODROPOFF
	+FORCEXYBILLBOARD
	+NOTELEPORT
	+FLOORCLIP
	-NOGRAVITY
	-NOBLOCKMAP
	+CLIENTSIDEONLY
	seesound "casings/ar_casing"
	states{
		spawn:
			ACSC ABCDEF 2
			loop
		death:
			NULL A 0 A_Jump(255, "pos1", "pos2", "pos3")
			NULL A 0
		pos1:
			ACSC B 400
			ACSC BBBBBBBBBB 1 A_FadeOut(0.1)
			stop
		pos2:
			ACSC C 400
			ACSC CCCCCCCCCC 1 A_FadeOut(0.1)
			stop
		pos3:
			ACSC F 400
			ACSC FFFFFFFFFF 1 A_FadeOut(0.1)
			stop
			
	}
}

actor cancasing_spawner {
	speed 15
	PROJECTILE
	+NOCLIP
	+CLIENTSIDEONLY
	states{
		spawn:
			NULL A 0
			NULL A 1 A_SpawnItemEx("cannon_casing", 0, 14, 3, 1, random(4,5), random(0,1), 0, SXF_TRANSFERPOINTERS) 
			stop
	}

}



//
actor cslugshot : FastProjectile{ 
    Radius 5
	Height 5  
	Mass 1
	Damage ((315+(10*random(0,3))) / 2)
	alpha 1
	Speed 100
	RenderStyle ADD
	Scale 0.30
	DamageType SlugImpact
	MissileType "cslugtrail_spawner"
	MissileHeight 8
	//ProjectileKickBack 110
	PROJECTILE
	+NOTELEPORT
	+FORCEXYBILLBOARD

	+THRUSPECIES
	Species "Player"
	
	States{
		Spawn:
			LEYS O 1 bright 
      		loop
		Death:
			TNT1 AA 0 A_PlaySound("sfx/cannonblast")
			TNT1 A 0 bright A_Explode (95 ,128)
			TNT1 A 0 A_SpawnItemEx ("cslugboom_flash", 0, 0, 0, 0, 0, 0, 0)
			TNT1 A 0 A_SpawnItemEx ("cslugshotboom", 0, 0, 0, 0, 0, 0, 0, 0)
			TNT1 A 0 A_SpawnItemEx ("cslugshotboom2", 0, 0, 0, 0, 0, 0, 0, 0)
			TNT1 A 0 A_SpawnItemEx ("cslugshotboom3", 0, 0, 0, 0, 0, 0, 0, 0)
			TNT1 A 0 A_SpawnItemEx ("cslugboom_wave", 0, 0, 0, 0, 0, 0, 0)
			TNT1 AAAAA 0 A_SpawnItemEx ("cslugboom_spark", 0, 0, 0, random(1,2), random(2,4) , random(0,6) , random(180,360))
			TNT1 AAA 0 A_SpawnItemEx ("cslugboom_spark2", 0, 0, 0, random(1,2), random(2,4) , random(0,6) , random(180,360))
			TNT1 A 3
			TNT1 AAAAAA 0 A_SpawnItemEx ("cslugboom_smoke", 0, 0, 0, random(0,1), /*f*/random(-1.8,1.8) , /*f*/random(-1.8,1.8) , random(0,90), 0)
			stop		
   	}
}

actor cslugtrail_spawner{
	+NOGRAVITY
	+NOCLIP
	+CLIENTSIDEONLY
	States{
		spawn:
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx ("cslugcoretrail", 0,0,0, 0,0,0, 0)
			TNT1 A 0 A_SpawnItemEx ("cslugtrail", 0,0,0, 0,0,0, 0)
			stop
	}
}

actor cslugcoretrail {
	scale 0.12
	alpha 1.0
	renderstyle add
	+NOINTERACTION
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+NOTELEPORT
	+CLIENTSIDEONLY
	states {
		spawn:
			SPRK C 2 bright
		sploop:
			TNT1 A 0 //A_SetScale(ScaleX * 0.8,ScaleY * 0.8)
			SPRK C 1 bright A_FadeOut(0.25)
			loop
	}		
}

actor cslugtrail {
	scale 0.08
	alpha 1.0
	renderstyle add
	+NOINTERACTION
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+NOTELEPORT
	+CLIENTSIDEONLY
	states {
		spawn:
			TNT1 A 0
			SMK1 ABCDEFGHIJKLMNOPQ 1 bright A_FadeOut(0.08)
			stop
	
	}
}


actor cslugshotboom {
	alpha 1
	RenderStyle ADD
	Scale 0.75
	+NOGRAVITY
	+NOBLOCKMAP
	+FLOORCLIP
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			SX06 ABCDEFGHIJKLMNOPQRSTUVWX 1 bright		
			stop
			
	}
}

actor cslugshotboom2 {
	alpha 1
	RenderStyle ADD
	Scale 1
	+NOGRAVITY
	+NOBLOCKMAP
	+FLOORCLIP
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 5
			SX05 BCDFG 1 bright	
		sploop:
			SX05 G 1 bright A_FadeOut(0.08)
			loop
			
	}
}

actor cslugshotboom3 {
	alpha 1
	RenderStyle ADD
	Scale 1
	+NOGRAVITY
	+NOBLOCKMAP
	+FLOORCLIP
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 2
			SX07 ABCDEFGHIJKLMNOP 1 bright
			stop
	}
}

actor cslugboom_flash {
	scale 0.74
	alpha 1.0
	renderstyle add
	+NOTELEPORT
	+NOCLIP
	+FLOORCLIP
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			BFSH A 3 bright
			stop
	}
}


actor cslugboom_spark {
	radius 2
	height 2
	alpha 1
	scale 0.04
	gravity 0.4
	renderstyle add
	+NOTELEPORT
	+FLOORCLIP
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	bouncetype "doom"
	bouncefactor 0.2
	states{
		spawn:
			SPRK A 15 bright
		spawnloop:
			SPRK A 1 bright A_FadeOut(0.1)
			loop
	}
}

actor cslugboom_spark2 : cslugboom_spark {
	scale 0.06
	gravity 0.3
	states{
		spawn:
			SPRK C 20 bright
		spawnloop:
			SPRK C 1 bright A_FadeOut(0.1)
			loop
	}
}



actor cslugboom_wave{
	//var int user_scale;
	alpha 0.8
	renderstyle add
	+NOINTERACTION
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_scale",3)
		scaledown1:
			TNT1 A 0 //A_SetScale((user_scale*0.018)) 
			TNT1 A 0 //A_JumpIf(user_scale>=30,"LoopEnd") 
			BSW0 A 1 bright A_FadeOut(0.09)
			TNT1 A 0 //A_SetUserVar("user_scale",user_scale+3)
			loop
		loopend:
			BSW0 B 1 Bright A_FadeOut(0.1)
			wait
			
	}
}


actor csteam_spawner {
	radius 1
	height 1
	speed 15
	PROJECTILE
	+NOCLIP
	+CLIENTSIDEONLY
	states{
		spawn:
			NULL A 1
			NULL A 0 
		death:
			NULL A 0 A_SpawnItemEx ("cannon_steam", 0, 0, 0, random(3,4), random(-1,1), 2, 0, SXF_TRANSFERPITCH)
			stop
	}
}

actor cannon_steam {
	radius 3
	height 3
	scale 0.12
	renderstyle add
	alpha 0.5
	damage 0
	speed 0
	+RIPPER
	+NOTELEPORT
	+NOCLIP
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	states{
		spawn:
			SMK4 ABCDEFGHIJ 1 A_Explode(2,4,0,0)
		endloop:
			TNT1 A 0 A_Explode(1,4,0,0)
			SMK4 J 1 A_FadeOut (0.1) 
			loop
	}
}