//=============================================================================
// sgBooster.
// * Revised by 7DS'Lust
//=============================================================================
class sgSuperBooster extends sgBuilding;

var sound           BoostSound;
var float           RepairTimer;

struct TPawnStr
{
 var pawn TPawn;
 var float FTime;
};
var TPawnStr TPStr[6];


simulated event Timer()
{
 local int i;
 
    Super.Timer();
    
    if ( DoneBuilding == True && Role == ROLE_Authority )
    {
     for(i=0;i<Arraycount(TPStr);i++)
     {
      if( TPStr[i].TPawn == None )
      {
       continue;
      }
      TPStr[i].FTime-=0.1;
      if( TPStr[i].FTime <= 0 )
      {
       TPStr[i].TPawn = None;
       continue;
      }
     }
    }
    
    if ( SCount > 0 || Role != ROLE_Authority || RepairTimer > 0 )
        return;

    Energy = FMin(Energy + 18, MaxEnergy);
}

simulated event Tick(float deltaTime)
{
    Super.Tick(deltaTime);

    if ( Role == ROLE_Authority && RepairTimer > 0 )
        RepairTimer -= deltaTime;
}

event TakeDamage( int Damage, Pawn instigatedBy, Vector hitLocation, 
  Vector momentum, name damageType)
{
    RepairTimer = 6;
    Super.TakeDamage(Damage * (1 - Grade*0.05), instigatedBy, hitLocation,
      momentum, damageType);
}

event Touch(Actor other)
{
    local int i;
    local int emptyslot;
    
    
    if (bDisabledByEMP){return;}
    if (!DoneBuilding){return;}
    if ( Pawn(Other) == None ){ return; }
    if ( !Pawn(other).bIsPlayer){return;} 
    if ( Pawn(other).PlayerReplicationInfo == None ){return;}
    if ( Pawn(other).PlayerReplicationInfo.Team != Team ){return;}
    
    emptyslot=-1;
    for(i=0;i<Arraycount(TPStr);i++)
    {
     if( TPStr[i].TPawn == Pawn(Other) )
     {
      return;
     }
     if( TPStr[i].TPawn == None )
     {
      emptyslot=i;
     }
    }

    if( emptyslot != -1 )
    {
     TPStr[emptyslot].TPawn=Pawn(Other);
     TPStr[emptyslot].FTime=0.3;
    }
    
    PendingTouch = other.PendingTouch;
    other.PendingTouch = self;
    PlaySound(BoostSound);
    PlaySound(BoostSound);
}

event PostTouch(Actor other)
{
    local Pawn target;
    local float boost;
    local float Zboost;
    
    
    
    
    if ( SCount > 0 || Pawn(other) == None )
    {
        return;
    }
    if (bDisabledByEMP){return;}
    target = Pawn(other);
    

    
    
    if ( target.IsA('Bot') )
    {
        if ( target.Physics == PHYS_Falling )
            Bot(target).bJumpOffPawn = true;
        Bot(target).SetFall();
    }
    if ( target.Physics != PHYS_Swimming )
        target.SetPhysics(PHYS_Falling);
    Zboost = 120 * (Grade + 5);
    boost = Grade;

        target.Velocity.X *= boost;
        target.Velocity.Y *= boost;
        target.Velocity.Z += Zboost;
}

defaultproperties
{
    BoostSound=Sound'UnrealI.Pickups.BootJmp'
    BuildingName="Super Booster"
    BuildCost=1200
    UpgradeCost=75
    BuildTime=15.00
    MaxEnergy=2500.00
    SpriteScale=0.50
    Model=LodMesh'Botpack.Crystal'
    SkinRedTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperBoosterSkinT0'
    SkinBlueTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperBoosterSkinT1'
    SkinGreenTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperBoosterSkinT2'
    SkinYellowTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperBoosterSkinT3'
    SpriteRedTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperBoosterSpriteT0'
    SpriteBlueTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperBoosterSpriteT1'
    SpriteGreenTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperBoosterSpriteT2'
    SpriteYellowTeam=Texture'SiegeUltimateRC7UB01Media.U.BuildingMaps.SuperBoosterSpriteT3'
    DSofMFX=1.25
    MFXrotX=(Pitch=50000,Yaw=50000,Roll=50000),
    MultiSkins(0)=Texture'SiegeUltimateRC7UB01Media.GFX.sgContSpriteT0'
    MultiSkins(1)=Texture'SiegeUltimateRC7UB01Media.GFX.sgContSpriteT1'
    MultiSkins(2)=Texture'SiegeUltimateRC7UB01Media.GFX.sgContSpriteT2'
    MultiSkins(3)=Texture'SiegeUltimateRC7UB01Media.GFX.sgContSpriteT3'
    CollisionHeight=30.00
}
