//=============================================================================
// WeaponPistolScope+Silencer.
//=============================================================================
class WeaponPistolSS extends NewPistol;


var float ZoomingScale, ZoomGrow, MaxZoom, MinZoom;

replication
{
	reliable if(Role<ROLE_Authority)
		UpdateScope;

	reliable if(Role==ROLE_Authority)
		ZoomingScale, ZoomIn, ZoomOut;

}




simulated function bool ClientFire( float value )
{
		if((Region.Zone.IsA('ArenaZoneSafe')) || (Region.Zone.IsA('MMRPGRoomArea')) || (Region.Zone.IsA('MMRPGSafeArea')))
		{
			return False;
		}

		if((!Region.Zone.IsA('ArenaZoneSafe')) && (!Region.Zone.IsA('MMRPGRoomArea')) && (!Region.Zone.IsA('MMRPGSafeArea')))
		{
			return Super.ClientFire(value);
		}
}


function UpdateScope(float ZoomFOV, bool bScoping)
{
	ScopeFOV = ZoomFOV;
	bZoomed  = bScoping;
	RefreshScopeDisplay(DeusExPlayer(Owner), False, bZoomed);
}


function ScopeOn()
{
	if (bHasScope && !bZoomed && Owner.IsA('DeusExPlayer'))
	{
		bZoomed = True;
		RefreshScopeDisplay(DeusExPlayer(Owner), False, bZoomed);
	}
}

function ScopeOff()
{
	if (bHasScope && bZoomed && Owner.IsA('DeusExPlayer'))
	{
		bZoomed = False;
		RefreshScopeDisplay(DeusExPlayer(Owner), False, bZoomed);
	}
}


simulated function RefreshScopeDisplay(DeusExPlayer player, bool bInstant, bool bScopeOn)
{
	if (bScopeOn && (Player !=None))
	{
		DeusExRootWindow(Player.RootWindow).ScopeView.ActivateView(ScopeFOV, False, bInstant);
	}

	else if (!bScopeOn)
	{
		DeusExRootWindow(Player.RootWindow).ScopeView.DeActivateView();
	}
}


function ScopeToggle()
{
	if(!bZoomed)
	{
		ScopeOn();
	}
	else
	{
		ScopeOff();
	}
}



simulated function bool ZoomOut()
{
	if(bZoomed)
	{
		bZoomed=True;

		if(ZoomingScale < MaxZoom)
		{
			ZoomingScale += ZoomGrow;

			//ZoomingScale=MaxZoom;
			ScopeFOV=80*ZoomingScale;
			UpdateScope(ScopeFOV,True);
		}
	}

	return bZoomed;
}

simulated function bool ZoomIn()
{
	if(bZoomed)
	{
		bZoomed=True;

		if(ZoomingScale > MinZoom)
		{
			ZoomingScale -= ZoomGrow;

			//ZoomingScale=MinZoom;
			ScopeFOV=80*ZoomingScale;
			UpdateScope(ScopeFOV,True);
		}

		return bZoomed;
	}
}

simulated event RenderOverlays( canvas Canvas )
{
	// set first person skin settings
		MultiSkins[0]=Texture'WeaponHandsTex';
		MultiSkins[1]=Texture'WeaponHandsTex';
		MultiSkins[2]=Texture'ContenderStuff.Skins.Pistol1';
		MultiSkins[3]=Texture'GlockScopeTex';
		MultiSkins[4]=Texture'SilencerTex1';

	Super(DeusExWeapon).RenderOverlays( Canvas );

	// reset third person skin settings
		MultiSkins[0]=Texture'ContenderStuff.Skins.Pistol3';
		MultiSkins[1]=Texture'ContenderStuff.Skins.Pistol3';
		MultiSkins[2]=Texture'GlockScopeTex';
		MultiSkins[3]=Texture'SilencerTex1';
}


defaultproperties
{
     MaxZoom=1.500000
     MinZoom=0.200000
     ZoomingScale=0.100000
     ZoomGrow=0.100000
     ScopeFOV=25
     HitDamage=10
     maxRange=4800
     AccurateRange=2400
     BaseAccuracy=0.800000
     bHasScope=True
     bCanHaveScope=True
     mpReloadTime=2.000000
     mpHitDamage=10
     mpBaseAccuracy=0.800000
     mpAccurateRange=1200
     mpMaxRange=1200
     InventoryGroup=164
     FireSound=Sound'DeusExSounds.Weapons.StealthPistolFire'
     ItemName="Colt M1911A1 .45 Pistol |p3[Silenced][Scoped]|p1"
     PlayerViewOffset=(X=22.000000,Y=-10.000000,Z=-14.000000)
     PlayerViewMesh=LodMesh'ContenderStuff.GlockSS1'
     PickupViewMesh=LodMesh'ContenderStuff.GlockSSPickup'
     ThirdPersonMesh=LodMesh'ContenderStuff.GlockSS3'
     Description="A standard 10mm pistol with a scope attached."
     beltDescription="COLT |p3(SI)(SC)|p1"
     Mesh=LodMesh'ContenderStuff.GlockSSPickup'
	MultiSkins(0)=Texture'ContenderStuff.Skins.Pistol3';
	MultiSkins(1)=Texture'ContenderStuff.Skins.Pistol3';
     Skin=None
     CollisionRadius=7.000000
     CollisionHeight=1.000000
}
