//=============================================================================
// Originally sgPlatform.
// Writen by Dim4 and nOs*Badger
// Lamely Copied but Tweaked to bypass lame siege rule.
// WildcardsPlatform.
// Higor: Changed collision hull, fixed repair issues, and some retarded stuff
//=============================================================================
class WildcardsPlatform expands sgBuilding;

var sgGenericCH TCH;
var float BaseEnergy;

var pawn rPlayers[16];
var int iP;

//The local player is standing here!
var PlayerPawn LocalStand;


simulated event PostBeginPlay()
{
	if ( Level.NetMode != NM_Client )
		SetLocation(Location-vect(0,0,17));
	else
		SetLocation(Location-vect(0,0,8));
	super.PostBeginPlay();
}


simulated function FinishBuilding()
{
	Super(sgBuilding).FinishBuilding();
	if (TCH == None)
	{
		TCH=Spawn(class'sgGenericCH',Self,'',Location,Rotation);
		if ( Level.NetMode == NM_Client )
			TCH.Setup( Self, 60, 15, vect(0,0,-1.7) );
		else
			TCH.Setup( Self, 60, 15, vect(0,0,1.7) );
		Texture=None;

		if (myFX!=None)
		{
			myFX.AmbientGlow=5;
			myFX.ScaleGlow=1.5;
		}
	}
}

simulated event Destruct( optional pawn instigatedBy)
{
	local Pawn p;

	foreach VisibleCollidingActors(class'Pawn', p, 95)
		if ( p.bIsPlayer && (p.Health > 0) && (p.PlayerReplicationInfo != None) )
			p.TakeDamage((Grade/2)+1 , instigator, vect(10,10,0), vect(10,10,0), 'sgSpecial');

	Super(sgBuilding).Destruct( instigatedBy);
}

function Upgraded()
{
	local float percent, scale;

	if ( BaseEnergy == 0 )
		BaseEnergy = MaxEnergy;

	percent = Energy/BaseEnergy;
	MaxEnergy = BaseEnergy * (1 + Grade/5);
	Energy = percent * BaseEnergy;
}

// Bring the building back to normal
function BackToNormal()
{
	Super.BackToNormal();
	LightType=LT_None;
	Texture=None;
}

function AlterNetRate()
{
	if ( Energy < MaxEnergy )
		NetUpdateFrequency = 10;
	else
		NetUpdateFrequency = 8;
}


defaultproperties
{
     BuildingName="Platform"
     BuildCost=200
     UpgradeCost=20
     BuildTime=5.000000
     MaxEnergy=2000.000000
     SpriteScale=1.000000
     Model=LodMesh'Botpack.DiscStud'
     SkinRedTeam=Texture'PlatformSkinT0'
     SkinBlueTeam=Texture'PlatformSkinT1'
     SpriteRedTeam=Texture'PlatformSpriteT0'
     SpriteBlueTeam=Texture'PlatformSpriteT1'
     DSofMFX=4.000000
     SkinGreenTeam=Texture'PlatformSkinT2'
     SkinYellowTeam=Texture'PlatformSkinT3'
     SpriteGreenTeam=Texture'PlatformSpriteT2'
     SpriteYellowTeam=Texture'PlatformSpriteT3'
     MFXrotX=(Yaw=10000)
     MultiSkins(0)=Texture'PlatformSpriteT0'
     MultiSkins(1)=Texture'PlatformSpriteT1'
     MultiSkins(2)=Texture'PlatformSpriteT2'
     MultiSkins(3)=Texture'PlatformSpriteT3'
     CollisionRadius=61.000000
     CollisionHeight=17.000000
     BuildDistance=50
     bStandable=True
}
