//=============================================================================
// 
//=============================================================================
class CopProd extends BOTDeusExWeapon;

var bool bDontDestroy;

simulated function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
	local float        mult;
	local name         damageType;
	local DeusExPlayer dxPlayer;
	local Teleporter   tele;
	local vector       loc;
	local float        rnd;
	local DeusExPlayer Player;

	rnd = FRand();

	if (rnd <= 0.25)
	{
		foreach allactors (class'Teleporter', tele)
		{
			If (tele.Tag == 'JAIL1')
			{
				loc = Tele.location;
			}
		}
	}

	else if ( (rnd > 0.25) && (rnd <= 0.5))
	{
		foreach allactors (class'Teleporter', tele)
		{
			If (tele.Tag == 'JAIL2')
			{
				loc = Tele.location;
			}
		}
	}

	else if ( (rnd > 0.5) && (rnd <= 0.75))
	{
		foreach allactors (class'Teleporter', tele)
		{
			If (tele.Tag == 'JAIL3')
			{
				loc = Tele.location;
			}
		}
	}

	else if (rnd > 0.75)
	{
		foreach allactors (class'Teleporter', tele)
		{
			If (tele.Tag == 'JAIL4')
			{
				loc = Tele.location;
			}
		}
	}


	if (Other != None)
	{
		// AugCombat increases our damage if hand to hand
		mult = 1.0;
		if (bHandToHand && (DeusExPlayer(Owner) != None))
		{
			mult = DeusExPlayer(Owner).AugmentationSystem.GetAugLevelValue(class'AugCombat');
			if (mult == -1.0)
				mult = 1.0;
		}

		// skill also affects our damage
		// GetWeaponSkill returns 0.0 to -0.7 (max skill/aug)
		mult += -2.0 * GetWeaponSkill();

		if ((Other.IsA('DeusExPlayer')) && (Other != Owner))
		{
			if ( Role == ROLE_Authority )
			{
				Other.SetLocation(loc);
				Other.SetPhysics(PHYS_Falling);
				DeusExPlayer(Other).ClientMessage("|p2You have been arrested!");
			}



//			Player = DeusExPlayer(Other);
//		Player.Mesh=LodMesh'MPCharacters.mp_jumpsuit';
//	        Player.MultiSkins[1]=Texture'DeusExCharacters.Skins.ThugMale3Tex2';
//	        Player.MultiSkins[2]=Texture'DeusExCharacters.Skins.ThugMale3Tex1';


//			Player.Mesh=LodMesh'DeusExCharacters.GM_DressShirt';
//			Player.MultiSkins[0]=Texture'DeusExCharacters.Skins.ThugMale2Tex0';
//			Player.MultiSkins[1]=Texture'DeusExItems.Skins.PinkMaskTex';
//			Player.MultiSkins[2]=Texture'DeusExItems.Skins.PinkMaskTex';
//			Player.MultiSkins[3]=Texture'DeusExCharacters.Skins.ThugMale2Tex2';
//			Player.MultiSkins[4]=Texture'DeusExCharacters.Skins.ThugMale2Tex0';
//			Player.MultiSkins[5]=Texture'DeusExCharacters.Skins.ThugMale2Tex1';
//			Player.MultiSkins[6]=Texture'DeusExItems.Skins.GrayMaskTex';
//			Player.MultiSkins[7]=Texture'DeusExItems.Skins.BlackMaskTex';
		}
	}
}

state NormalFire
{
	function AnimEnd()
	{
		if (bAutomatic)
		{
			if ((Pawn(Owner).bFire != 0) && (AmmoType.AmmoAmount > 0))
			{
				if (PlayerPawn(Owner) != None)
					Global.Fire(0);
				else 
					GotoState('FinishFire');
			}
			else 
				GotoState('FinishFire');
		}
		else
		{
			// if we are a thrown weapon and we run out of ammo, destroy the weapon
			if (bHandToHand && (ReloadCount > 0) && (AmmoType.AmmoAmount <= 0))
				Destroy();
		}
	}
	function float GetShotTime()
	{
		local float mult, sTime;

		if (ScriptedPawn(Owner) != None)
			return ShotTime * (ScriptedPawn(Owner).BaseAccuracy*2+1);
		else
		{
			// AugCombat decreases shot time
			mult = 1.0;
			if (bHandToHand && DeusExPlayer(Owner) != None)
			{
				mult = 1.0 / DeusExPlayer(Owner).AugmentationSystem.GetAugLevelValue(class'AugCombat');
				if (mult == -1.0)
					mult = 1.0;
			}
			sTime = ShotTime * mult;
			return (sTime);
		}
	}

Begin:
	if ((ClipCount >= ReloadCount) && (ReloadCount != 0))
	{
		if (!bAutomatic)
		{
			bFiring = False;
			FinishAnim();
		}

		if (Owner != None)
		{
			if (Owner.IsA('DeusExPlayer'))
			{
				bFiring = False;

				// should we autoreload?
				if (DeusExPlayer(Owner).bAutoReload)
				{
					// auto switch ammo if we're out of ammo and
					// we're not using the primary ammo
					if ((AmmoType.AmmoAmount == 0) && (AmmoName != AmmoNames[0]))
						CycleAmmo();
					ReloadAmmo();
				}
				else
				{
					if (bHasMuzzleFlash)
						EraseMuzzleFlashTexture();
					GotoState('Idle');
				}
			}
			else if (Owner.IsA('ScriptedPawn'))
			{
				bFiring = False;
				ReloadAmmo();
			}
		}
		else
		{
			if (bHasMuzzleFlash)
				EraseMuzzleFlashTexture();
			GotoState('Idle');
		}
	}
	if ( bAutomatic && (( Level.NetMode == NM_DedicatedServer ) || ((Level.NetMode == NM_ListenServer) && Owner.IsA('DeusExPlayer') && !DeusExPlayer(Owner).PlayerIsListenClient())))
		GotoState('Idle');

	Sleep(GetShotTime());
	if (bAutomatic)
	{
		GenerateBullet();	// In multiplayer bullets are generated by the client which will let the server know when
		Goto('Begin');
	}
	bFiring = False;
	FinishAnim();

	// if ReloadCount is 0 and we're not hand to hand, then this is a
	// single-use weapon so destroy it after firing once
	if ((ReloadCount == 0) && !bDontDestroy)
	{
		if (DeusExPlayer(Owner) != None)
			DeusExPlayer(Owner).RemoveItemFromSlot(Self);   // remove it from the inventory grid
		Destroy();
	}
	ReadyToFire();
Done:
	bFiring = False;
	Finish();
}

defaultproperties
{
     bDontDestroy=True
     LowAmmoWaterMark=6
     GoverningSkill=Class'DeusEx.SkillWeaponPistol'
     EnviroEffective=ENVEFF_Air
     Concealability=CONC_Visual
     ShotTime=0.600000
     reloadTime=2.000000
     HitDamage=0
     maxRange=4800
     AccurateRange=2400
     BaseAccuracy=0.700000
     bCanHaveScope=True
     ScopeFOV=25
     bCanHaveLaser=True
     recoilStrength=0.300000
     mpReloadTime=2.000000
     mpHitDamage=0
     mpBaseAccuracy=0.200000
     mpAccurateRange=1200
     mpMaxRange=1200
     mpReloadCount=9
     bCanHaveModBaseAccuracy=True
     bCanHaveModReloadCount=True
     bCanHaveModAccurateRange=True
     bCanHaveModReloadTime=True
     bCanHaveModRecoilStrength=True
     AmmoName=Class'DeusEx.AmmoNone'
     ReloadCount=0
     PickupAmmoCount=0
     bInstantHit=True
     FireOffset=(X=-22.000000,Y=10.000000,Z=14.000000)
     shakemag=50.000000
     FireSound=Sound'DeusExSounds.Weapons.PistolFire'
     CockingSound=Sound'DeusExSounds.Weapons.PistolReload'
     SelectSound=Sound'DeusExSounds.Weapons.PistolSelect'
     InventoryGroup=110
     ItemName="Jail Teleporter"
     PlayerViewOffset=(X=22.000000,Y=-10.000000,Z=-14.000000)
     PlayerViewMesh=LodMesh'DeusExItems.Glock'
     PickupViewMesh=LodMesh'DeusExItems.GlockPickup'
     ThirdPersonMesh=LodMesh'DeusExItems.Glock3rd'
     Icon=Texture'DeusExUI.Icons.BeltIconPistol'
     largeIcon=Texture'DeusExUI.Icons.LargeIconPistol'
     largeIconWidth=46
     largeIconHeight=28
     Description="A standard 10mm pistol."
     beltDescription="JAIL TELE"
     Mesh=LodMesh'DeusExItems.GlockPickup'
     CollisionRadius=7.000000
     CollisionHeight=1.000000
}
