class MMRPGCreditCard extends DeusExPickup;

#exec TEXTURE IMPORT NAME=CreditCardTex FILE=Textures\CreditCardTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=WeaponListTex FILE=Textures\WeaponListTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=ClothesListTex FILE=Textures\ClothesListTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=WeaponSignTex FILE=Textures\WeaponSignTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=NoWeapsTex FILE=Textures\NoWeapsTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=AutoCardListsTex FILE=Textures\AutoCardListTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=ToolsTex FILE=Textures\ToolsTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=CredCardHelp FILE=Textures\CredCardHelp.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=NoKillTex FILE=Textures\NoKillTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=BankSignTex FILE=Textures\BankSignTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=RoomListTex FILE=Textures\RoomListTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=FurnListTex FILE=Textures\FurnListTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=PawnListTex FILE=Textures\PawnListTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=ArmourListTex FILE=Textures\ArmourListTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=SkateList FILE=Textures\SkateList.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=testtex FILE=Textures\testtex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=ClothesShop FILE=Textures\ClothesShop.bmp GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=GunsListTex FILE=Textures\GunsListTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=GrenListTex FILE=Textures\GrenListTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=ModsListTex FILE=Textures\ModsListTex.bmp GROUP=Skins
#exec TEXTURE IMPORT NAME=CorpListTex FILE=Textures\CorpListTex.bmp GROUP=Skins

var int CreditAmount;
var int CredFire;


replication
{
    reliable if ( Role < ROLE_Authority )
	Switcharoo, CreditFire;

    reliable if( Role==ROLE_Authority)
	CreditAmount;
}


//=================================================================================
//=================================================================================
//=================================================================================





function PlayIdleAnim()
{
	local float rnd;

	rnd = FRand();

	if (rnd < 0.3)
		PlayAnim('Idle1');
	else if (rnd < 0.6)
		PlayAnim('Idle2');
}


function GiveTo( pawn Other )
{	
	SetCardOwner(_MMRPGPlayer(Other));
	Super.GiveTo(Other);
	GotoState('Idle2');
}


function PlayBringUp()
{
	//PlayAnim('Select',, 0.1);
	PlayAnim('Idle2',, 0.2);
	if (!IsInState('Idle'))
		GotoState('Idle');
}

function PlayPutDown()
{
	if (IsInState('Idle'))
		GotoState('DownItem');
}

state Idle
{
	function Timer()
	{
		PlayIdleAnim();
	}

Begin:
	//bHidden = False;
	bOnlyOwnerSee = True;
	FinishAnim();
	//PlayAnim('Idle1',, 0.1);
	//PlayIdleAnim();
	SetTimer(3.0, True);
}

state DownItem
{
	function PlayPutDown()
	{
		
	}

Begin:
	AmbientSound = None;
	bHidden = False;		// make sure we can see the animation
	PlayAnim('Down',, 0.1);
	FinishAnim();
	bHidden = True;	// hide it correctly
	GotoState('Idle2');
}

//=================================================================================
//=================================================================================
//=================================================================================





// ----------------------------------------------------------------------
state Activated
{
	function Activate()
	{
		// can't turn it off
	}

	function BeginState()
	{
		local _MMRPGPlayer player;
		
		Super.BeginState();

		player = _MMRPGPlayer(Owner);
		if (player != None)
		{
			CreditFire();
		}

	//GotoState('DeActivated');
GotoState('Idle');
	}


Begin:
}


Function Switcharoo()
{
	if(CredFire == 1)
	{
		CredFire = 5;
		Pawn(Owner).ClientMessage("5 credit notes selected");
		return;
	}

	if(CredFire == 5)
	{
		CredFire = 10;
		Pawn(Owner).ClientMessage("10 credit notes selected");
		return;
	}

	if(CredFire == 10)
	{
		CredFire = 1;
		Pawn(Owner).ClientMessage("1 credit notes selected");
		return;
	}
}

function CreditFire()
{
	local vector loc;
	local MMRPGCreditsProjectile SpawnObject;
	local MMRPGCreditsProjectileFive SpawnObject5;
	local MMRPGCreditsProjectileTen SpawnObject10;

	loc = Pawn(Owner).Location;
	loc.Z += Pawn(Owner).BaseEyeHeight;

	if(CreditAmount <= 0)
	{
		CreditAmount = 0;
		DeusExPlayer(Owner).ClientMessage("|p2No Credits!");
		return;
	}

	if(CredFire == 1)
	{
		if (CreditAmount > 0)
		{
			SpawnObject = Spawn(class'MMRPGCreditsProjectile',,, loc, Pawn(Owner).ViewRotation);
			//DeusExPlayer(Owner).ClientMessage("|p3Paid 1 credit");
			CreditAmount-=1;
			SpawnObject.PawnOwner = Pawn(Owner);
		}
	}

	if(CredFire == 5)
	{
		if (CreditAmount >= 5)
		{
			SpawnObject5 = Spawn(class'MMRPGCreditsProjectileFive',,, loc, Pawn(Owner).ViewRotation);
			//DeusExPlayer(Owner).ClientMessage("|p5Paid 5 credits");
			CreditAmount-=5;
			SpawnObject5.PawnOwner = Pawn(Owner);
		}
		else DeusExPlayer(Owner).ClientMessage("|p2Not enough money for a 5c. note!");
	}

	if(CredFire == 10)
	{
		if (CreditAmount >= 10)
		{
			SpawnObject10 = Spawn(class'MMRPGCreditsProjectileTen',,, loc, Pawn(Owner).ViewRotation);
			//DeusExPlayer(Owner).ClientMessage("|p4Paid 10 credits");
			CreditAmount-=10;
			SpawnObject10.PawnOwner = Pawn(Owner);
		}
		else DeusExPlayer(Owner).ClientMessage("|p2Not enough money for a 10c. note!");
	}
}

simulated function bool TestMPBeltSpot(int BeltSpot)
{
   return (BeltSpot == 0);
}


function DropFrom(vector StartLocation)
{
	CCheck();
}

Function CCheck()
{
	DeusExPlayer(Owner).ClientMessage("|p2Credit balance: "$CreditAmount);
}

Function SetCardOwner(_MMRPGPlayer ThisGuy)
{
	ThisGuy.SetCard(Self);
}


defaultproperties
{
     ThirdPersonScale=0.35
     M_Activated=""
     bActivatable=True
     CredFire=1
     CreditAmount=0
     InventoryGroup=254
     ItemName="Credit card"
     PlayerViewOffset=(X=30.000000,Z=-12.000000)
     PlayerViewMesh=LodMesh'ContenderStuff.credcard1'
     PickupViewMesh=LodMesh'ContenderStuff.credcardpickup'
     ThirdPersonMesh=LodMesh'ContenderStuff.credcard3'
     LandSound=Sound'DeusExSounds.Generic.PlasticHit1'
     Icon=Texture'ContenderStuff.Icons.BeltIconCred'
     LargeIcon=Texture'ContenderStuff.Icons.BeltIconCred'
     Description="credz"
     beltDescription="CREDIT CARD"
     Mesh=LodMesh'ContenderStuff.credcardpickup'
     CollisionRadius=7.000000
     CollisionHeight=0.550000
     Mass=2.000000
     Buoyancy=3.000000
}
