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

UnrealShare.BabyCow


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
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
//=============================================================================
// BabyCow.
// Don't add to world directly.  Rather, set bHasBaby of an adult cow.
//=============================================================================
class BabyCow expands Cow;

var Cow mom;

function PlayRunning()
{
    LoopAnim('Run', -1.5/GroundSpeed,,0.3);
}

function PlayWalking()
{
    LoopAnim('Walk', -2.0/GroundSpeed,,0.3);
}

function FollowMom()
{
    Disable('AnimEnd');
    GotoState('Grazing', 'Wander');
}
                

state Grazing
{
    
    function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, 
                        Vector momentum, name damageType)
    {
        Mom.Help(self);
        Global.TakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType);
        if ( health <= 0 )
            return;
        if ( NextState == 'TakeHit' )
            {
            NextState = 'Attacking'; 
            NextLabel = 'Begin';
            GotoState('TakeHit'); 
            }
        else
            GotoState('Attacking');
    }

    function Bump(actor Other)
    {
        if ( (Pawn(Other)!= None) && (Cow(Other) == None) && (MoveTimer < 0) )
            GotoState('Grazing', 'Wander'); 
        else if ( (Normal(Destination - Location) Dot Normal(Other.Location - Location)) > 0.8 )
            MoveTimer = -1.0;
        Disable('Bump');
    }
    
    function PickDestination()
    {
        if ( Mom == None )
            Super.PickDestination();
        if ( !LineOfSightTo(mom) )
        {
            MoveTarget = FindPathToward(mom);
            if ( MoveTarget != None )
            {
                Destination = MoveTarget.Location;
                return;
            }
        }       
        if (ScaryGuy != None)
            Destination = mom.Destination - 2 * mom.CollisionRadius * Normal(ScaryGuy.Location - mom.Destination);
        else
            Destination = mom.Destination;
    }

Begin:
    //log(class$" Grazing");

Wander: 
    if (!bForage)
        Goto('Graze');
    PickDestination();
    TweenToWalking(0.2);
    FinishAnim();
    PlayWalking();
    
Moving:
    Enable('HitWall');
    Enable('Bump');
    MoveTo(Destination, 0.4);
    Acceleration = vect(0,0,0);
Graze:
    Enable('AnimEnd');
    NextAnim = '';
    TweenToPatrolStop(0.2);
    Sleep(4);
    Disable('AnimEnd');
    FinishAnim();
    Goto('Wander');

ContinueWander:
    FinishAnim();
    PlayWalking();
    Goto('Wander');

Turn:
    PlayTurning();
    TurnToward(Mom);
    Goto('Graze');  
}

defaultproperties
{
     Health=40
     DrawScale=0.500000
     CollisionRadius=24.000000
     CollisionHeight=16.000000
     Mass=70.000000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Sun 21/2/2010 23:48:40.000 - Creation time: Sun 21/2/2010 23:49:51.134 - Created with UnCodeX