Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

# Gameplay.MPGoal

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
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152

    class MPGoal extends MPActor;

    var() int		teamGoalScore			"The number of points an attacker scores for his team when a goal is scored";
    var() int		individualGoalScore		"The number of points an attacker scores for himself when a goal is scored";
    var() Material	goalMaterial			"The material the ball must touch in order to score a goal";

    // Effects
    var bool bGoalEffect;
    var bool bLocalGoalEffect;
    var() name goalScoredAnimation			"The name of an animation to play when a goal is scored";
    var(EffectEvents) name goalScoredEffectEvent	"The name of an effect event that plays once on the goal when a goal is scored.";
    var MPBall ballRef;
    var bool bInitialization;

    replication
    {
    	reliable if (Role == ROLE_Authority)
    		bGoalEffect;
    }

    // PostBeginPlay
    function PostBeginPlay()
    {
    	Super.PostBeginPlay();
    }

    simulated function PostNetReceive()
    {
    	Super.PostNetReceive();

    	updateGoalEffects();
    }

    simulated function updateGoalEffects()
    {
    	if (bGoalEffect != bLocalGoalEffect)
    	{
    		bLocalGoalEffect = bGoalEffect;

    		if (!bInitialization)
    		{
    			if (team() != None)
    				TriggerEffectEvent(goalScoredEffectEvent,,,,,,,,team().Class.name);
    			else
    				TriggerEffectEvent(goalScoredEffectEvent);
    			if (hasAnim(goalScoredAnimation))
    				PlayAnim(goalScoredAnimation);
    		}
    	}

    	bInitialization = false;
    }

    // Bump
    function Touch(Actor Other)
    {
    	local MPBall ball;
    	local TeamInfo t;
        local Vector HitLocation, HitNormal, StartTrace, EndTrace;
    	local Actor Check;
        local Material MaterialHit;
    	local int i;

    	ball = MPBall(Other);
    	if (ball == None)
    		return;

    	// Check for goal by determining the material the ball hit
    	StartTrace = Other.Location;
    	EndTrace = Location;// + (Normal(Other.Velocity) * 100.0);

    	Check = Other.Trace( HitLocation, HitNormal, EndTrace, StartTrace, true, vect(0,0,0), MaterialHit );

    	//Log("GOAL check ="$Check$", mat = "$MaterialHit$", start = "$StartTrace$", end = "$EndTrace$", vel = "$Other.Velocity);

    	if (MaterialHit != goalMaterial)
    	{
    		//Other.HitWall(HitNormal, self);
    		// Remove from touching array so that touch is called again
    		for (i=0; i<Touching.Length; i++)
    		{
    			if (Touching[i] == ball)
    				Touching.Remove(i, 1);
    		}

    		return;
    	}

    	// Hide the ball and wait half a second before returning it
    	// This is partly to handle the case where someone scores from point blank range, which
    	// can result in state confusion
    	ball.bHidden = true;
    	ballRef = ball;
    	SetTimer(0.5, false);
    	bGoalEffect = !bGoalEffect;
    	updateGoalEffects();

    	if (ball.lastCarrier.team() != team())
    	{
    		scoreTeam(teamGoalScore, ball.lastCarrier.team());
    		scoreIndividual(ball.lastCarrier, individualGoalScore);
    		//Level.Game.Broadcast(self, "GOOOOOOOOOOOOOOAAAAL!!!");
    		Level.Game.BroadcastLocalized(self, ball.Class.default.CarryableMessageClass, 5, ball.lastCarrier.team());

    		if (ball.Class.default.SecondaryMessageClass != None)
    			Level.Game.BroadcastLocalized(self, ball.Class.default.SecondaryMessageClass, 5, ball.lastCarrier.playerReplicationInfo);

    		dispatchMessage(new class'MessageGoalScored'(label, ball.lastCarrier.label, ball.lastCarrier.getTeamLabel(), ball.label));
    	}
    	else
    	{
    		// If someone scores on their own team's goal, all other teams get a point
    		ForEach DynamicActors(class'TeamInfo', t)
    		{
    			if (t != ball.lastCarrier.team())
    			{
    				dispatchMessage(new class'MessageGoalScored'(label, ball.lastCarrier.label, t.label, ball.label));
    				scoreTeam(teamGoalScore, t);
    			}
    		}
    	}
    }

    function Timer()
    {
    	ballRef.onGoal(self);
    	ballRef.bHidden = false;
    	ballRef = None;
    }

    defaultproperties
    {
    	DrawType				= DT_StaticMesh
    	StaticMesh				= StaticMesh'MPGameObjects.goal'
    	bCollideActors			= true
    	bCollideWorld			= true
    	bBlockActors			= true
    	bBlockPlayers			= true
    	bMovable				= false
    	bNetNotify				= true
    	//bUseCylinderCollision	= true

    	teamGoalScore			= 1
    	individualGoalScore		= 10

    	goalMaterial			= Material'MPGameObjects.GoalMouthShader'
    	goalScoredEffectEvent	= Scored

    	bSkipEncroachment		= true

    	bInitialization = true
    }

Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

Class file time: ne 5.9.2004 15:53:18.000 - Creation time: st 23.5.2018 00:10:45.929 - Created with UnCodeX