Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

DeusEx.Cart


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
00077
00078
00079
00080
//=============================================================================
// Cart.
//=============================================================================
class Cart extends DeusExDecoration;

var float rollTimer;
var float pushTimer;
var vector pushVel;
var bool bJustPushed;

function StartRolling(vector vel)
{
    // Transfer momentum
    SetPhysics(PHYS_Rolling);
    pushVel = vel;
    pushVel.Z = 0;
    Velocity = pushVel;
    rollTimer = 2;
    bJustPushed = True;
    pushTimer = 0.5;
    AmbientSound = Sound'UtilityCart';
}

//
// give us velocity in the direction of the push
//
function Bump(actor Other)
{
    if (bJustPushed)
        return;

    if ((Other != None) && (Physics != PHYS_Falling))
        if (abs(Location.Z-Other.Location.Z) < (CollisionHeight+Other.CollisionHeight-1))  // no bump if landing on cart
            StartRolling(0.25*Other.Velocity*Other.Mass/Mass);
}

//
// simulate less friction (wheels)
//
function Tick(float deltaTime)
{
    Super.Tick(deltaTime);

    if ((Physics == PHYS_Rolling) && (rollTimer > 0))
    {
        rollTimer -= deltaTime;
        Velocity = pushVel;

        if (pushTimer > 0)
            pushTimer -= deltaTime;
        else
            bJustPushed = False;
    }


    // make the sound pitch depend on the velocity
    if (VSize(Velocity) > 1)
    {
        SoundPitch = Clamp(2*VSize(Velocity), 32, 64);
    }
    else
    {
        // turn off the sound when it stops
        AmbientSound = None;
        SoundPitch = Default.SoundPitch;
    }
}

defaultproperties
{
     bCanBeBase=True
     ItemName="Utility Push-Cart"
     Mesh=LodMesh'DeusExDeco.Cart'
     SoundRadius=16
     CollisionRadius=28.000000
     CollisionHeight=26.780001
     Mass=40.000000
     Buoyancy=45.000000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 8/11/2021 16:22:52.000 - Creation time: Mon 8/11/2021 16:31:23.480 - Created with UnCodeX