# SFVehicle.SFHoverCraft

00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 |
    //=============================================================================
    // Spatial Fear
    // Name: SFHovercraft
    // Description: A vehicle class with hover craft-like behavior; floats around
    //
    // Author: Gert Jen Peltenburg
    //=============================================================================
    class SFHoverCraft expands SFVehicle;

    simulated function InterpretControls(bool bJustFired,bool bFire,bool bJustAltFired,bool bAltFire,
                               float aVehicleSpeedControl,float aTurretTurn,float aVehicleTurn,
                               float aVehicleUp,float aTurretUp,bool bJustJumped,bool bJustDucked)
    {
     local float NewDesiredSpeed;

     if(aVehicleTurn<0)
      controlinputYaw = (aVehicleTurn/16384.0)*YawLeftRate;
     else
      controlinputYaw = (aVehicleTurn/16384.0)*YawRightRate;

     NewDesiredSpeed = 0;

     if(aVehicleSpeedControl<0)
      NewDesiredSpeed = MinSpeed/16384.0*abs(aVehicleSpeedControl);

     if(aVehicleSpeedControl>0)
      NewDesiredSpeed = MaxSpeed/16384.0*abs(aVehicleSpeedControl);

     DesiredSpeed = NewDesiredSpeed;
    }

    // UpdateSpeed overridden because hovercraft can slide
    simulated function UpdateSpeed(float DeltaTime,float traction)
    {
     local float accel;

     accel=0.0;
     if(MaxSpeed>0) {
      if(DesiredSpeed<CurrentSpeed) {
       if(CurrentSpeed>0.0 && MaxDeceleration>MaxReverseAcceleration)
        accel=MAX(DesiredSpeed-CurrentSpeed,-MaxDeceleration*deltatime*traction); // note: desiredspeed-currentspeed is negative, so accel is negative
       else
        accel=MAX(DesiredSpeed-CurrentSpeed,-MaxReverseAcceleration*deltatime*traction); // note: desiredspeed-currentspeed is negative, so accel is negative
      }
      if(DesiredSpeed>CurrentSpeed) {
       if(CurrentSpeed<0.0 && MaxDeceleration>MaxAcceleration)
        accel=MIN(DesiredSpeed-CurrentSpeed,MaxDeceleration*deltatime*traction);
       else
        accel=MIN(DesiredSpeed-CurrentSpeed,MaxAcceleration*deltatime*traction);
      }
     }
     CurrentSpeed+=accel;
     if(CurrentSpeed>MaxSpeed*traction)
      CurrentSpeed=MaxSpeed*traction;
     else
     if(CurrentSpeed<MinSpeed*traction)
      CurrentSpeed=MinSpeed*traction;

     linearvelocity = CurrentSpeed*vector(CurrentRotation);
    }

    defaultproperties
    {
         bBot_ShowVehicleLocation=True
         DestructionEffect=None
         PhysicsFlatBottom=True
         PhysicsHover=True
         PhysicalRotationRate=(Pitch=0,Yaw=0,Roll=0)
         Elasticity=0.000000
         bRepairable=False
         RepairTime=0.000000
         bDamageTriggered=True
         Buoyancy=100.000000
    }

class file time: 12/7/2003 3:58:26 PM - creation time: 12/7/2003 4:03:44 PM
Created with UnCodeX