//=============================================================================
// sgWarhead.
// * Revised by 7DS'Lust
//=============================================================================
class sgWarhead extends sgItem;

//var bool Played;
var class<CriticalEventPlus> MessageClass;
var Pawn Damager;
var string sBuildMessage;

function AnnounceTeam(string sMessage, int iTeam)
{
    local Pawn p;

    for ( p = Level.PawnList; p != None; p = p.nextPawn )
	    if ( (p.bIsPlayer || p.IsA('MessagingSpectator')) &&
          p.PlayerReplicationInfo != None && p.playerreplicationinfo.Team == iTeam )
		    p.ClientMessage(sMessage);
}

function PostBeginPlay()
{
	local Pawn p;
	local string sLocation;

	Super.PostBeginPlay();

    if ( MessageClass == None )
        return;

	for ( p = Level.PawnList; p != None; p = p.nextPawn )
	{
		if ( p.IsA('TournamentPlayer' ) && p.PlayerReplicationInfo != None && 
          p.PlayerReplicationInfo.Team != Team )
			p.ReceiveLocalizedMessage(MessageClass, Team);
	}



        if ( Pawn(owner).PlayerReplicationInfo.PlayerLocation != None )
            sLocation = PlayerReplicationInfo.PlayerLocation.LocationName;
        else if ( Pawn(owner).PlayerReplicationInfo.PlayerZone != None )
            sLocation = Pawn(owner).PlayerReplicationInfo.PlayerZone.ZoneName;
	if ( sLocation != "" && sLocation != " ")
	    sLocation = "at"@sLocation;
	sgPRI(Pawn(owner).PlayerReplicationInfo).sgInfoWarheadMaker++;

	AnnounceTeam(sBuildMessage@BuildingName@sLocation, Team);
}

event TakeDamage( int damage, Pawn instigatedBy, Vector hitLocation, 
  Vector momentum, name damageType )
{
    Damager = instigatedBy;
    Super.TakeDamage(damage, instigatedBy, hitLocation, momentum, damageType);
}

function Destruct()
{
    local PlayerReplicationInfo pri1, pri2;
    if ( Pawn(Owner) != None )
        pri1 = Pawn(Owner).PlayerReplicationInfo;
    if ( Damager != None )
        pri2 = Damager.PlayerReplicationInfo;
    BroadcastLocalizedMessage(class'sgBuildingKillMsg',, pri1, pri2,
      Self);
    sgPRI(Damager.PlayerReplicationInfo).sgInfoWarheadKiller++;
    Super.Destruct();
}

function PlayFinishSound()
{
    PlaySound(FinishSound, SLOT_None, 5);
}

function Inventory GiveItem(Pawn target)
{
    local Pawn p;
	local NukeSiren tehsiren;
    local Inventory inv;
    inv = Super.GiveItem(target);
    if ( inv != None )
    {
        target.PlaySound(sound'SiegeUltimateRC7UB01Media.sgGetNuke', SLOT_None,
          target.SoundDampening*3);
    }

    return inv;
}


defaultproperties
{
    MessageClass=Class'sgNukeBuildMsg'
    sBuildMessage="Your team has built a"
    FinishSound=Sound'SiegeUltimateRC7UB01Media.SFX.sgWarAppear'
    InventoryClass=Class'sgNukeLauncher'
    AmmoAmount=1
    SwitchToWeapon=True
    BuildingName="Warhead"
    BuildCost=1300
    UpgradeCost=200
    BuildTime=120.00
    Model=LodMesh'Botpack.missile'
    SkinRedTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSkinT0'
    SkinBlueTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSkinT1'
    SkinGreenTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSkinT2'
    SkinYellowTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperContainerSkinT3'
    SpriteRedTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.CoreSpriteTeam0'
    SpriteBlueTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.CoreSpriteTeam1'
    SpriteGreenTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.CoreSpriteTeam2'
    SpriteYellowTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.CoreSpriteTeam3'
    DSofMFX=1.50
    
    bNoUpgrade=True
}
