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

UnrealI.Dice


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
//=============================================================================
// Dice.
//=============================================================================
class Dice expands Decoration;

#exec MESH IMPORT MESH=DiceM ANIVFILE=MODELS\dice_a.3D DATAFILE=MODELS\dice_d.3D X=0 Y=0 Z=0 ZEROTEX=1
#exec MESH ORIGIN MESH=DiceM X=0 Y=0 Z=0 YAW=64
#exec MESH SEQUENCE MESH=DiceM SEQ=All    STARTFRAME=0   NUMFRAMES=1
#exec MESH SEQUENCE MESH=DiceM SEQ=Still  STARTFRAME=0   NUMFRAMES=1
#exec TEXTURE IMPORT NAME=JDice1 FILE=MODELS\Dice.PCX GROUP=Skins

#exec MESHMAP SCALE MESHMAP=DiceM X=0.006 Y=0.006 Z=0.012
#exec MESHMAP SETTEXTURE MESHMAP=DiceM NUM=0 TEXTURE=JDice1

var bool bHasBounced;
var int numBounces;

function Throw(vector Y)
{
    bHidden = false;
    numBounces = 0;
    Roll();
    Velocity = 40 * VRand() - 80 * FRand() * Y;
    SetPhysics(PHYS_Falling);
}

simulated function Roll()
{
    DesiredRotation.Pitch = 16384 * Rand(4);    
    DesiredRotation.Yaw = 16384 * Rand(4);
    DesiredRotation.roll = 16384 * Rand(4);
}

auto state Playing
{
    ignores BaseChange, Bump;

    simulated function HitWall (vector HitNormal, actor Wall)
    {
        local vector landspot;

        numBounces++;
        if ( (instigator == None) || (numBounces > 20) )
        {
            bBounce = false;
            Velocity.Z = -0.5 * Velocity.Z;
            return;
        }
        landspot = instigator.location + vector(instigator.rotation) * 2.3 * instigator.CollisionRadius;
        landspot.Z = location.Z;
        
        if ( bHasBounced && (Vsize(landspot - location) < 15) )
        {
            SetPhysics(PHYS_None);
            SetRotation(DesiredRotation);
            return;
        }

        Velocity = landspot - location + 3 * VRand();
        Velocity.Z *= -0.6;
        if (Velocity.Z < 50) 
            Velocity.Z = 50;
        bHasBounced = True;
        Roll();
        //PlaySound(ImpactSound);
    }
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: za 22-4-2006 12:52:32.000 - Creation time: za 22-4-2006 12:53:45.031 - Created with UnCodeX