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

UTGame.UTWillowWhisp


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
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
/**
 *
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */


/** used to show the path to game objectives */
class UTWillowWhisp extends UTReplicatedEmitter;

const MAX_WAYPOINTS = 15;

/** path points to travel to */
var vector WayPoints[MAX_WAYPOINTS];
/** total number of valid points in WayPoints list */
var repnotify int NumPoints;
/** current position in WayPoints list */
var int Position;

replication
{
	if (bNetInitial)
		NumPoints, WayPoints;
}

simulated function PostBeginPlay()
{
	local int i, Start;
	local PlayerController P;
	local Actor HitActor;
	local Vector HitLocation,HitNormal;

	Super.PostBeginPlay();

	if (Role == ROLE_Authority)
	{
		P = PlayerController(Owner);
		if (P == None || P.Pawn == None)
		{
			Destroy();
		}
		else
		{
			SetLocation(P.Pawn.Location);

			WayPoints[0] = Location + P.Pawn.GetCollisionHeight() * vect(0,0,1) + 200.0 * vector(P.Rotation);
			HitActor = Trace(HitLocation, HitNormal, WayPoints[0], Location, false);
			if (HitActor != None)
			{
				WayPoints[0] = HitLocation;
			}
			NumPoints++;

			if (P.RouteCache[0] != None && P.RouteCache.length > 1 && P.ActorReachable(P.RouteCache[1]))
			{
				Start = 1;
			}
			for (i = Start; NumPoints < MAX_WAYPOINTS && i < P.RouteCache.length && P.RouteCache[i] != None; i++)
			{
				WayPoints[NumPoints++] = P.RouteCache[i].Location + P.Pawn.GetCollisionHeight() * Vect(0,0,1);
			}
		}
	}
}

simulated event SetInitialState()
{
	bScriptInitialized = true;

	if (Role == ROLE_Authority)
	{
		if (PlayerController(Owner).IsLocalPlayerController())
		{
			StartNextPath();
		}
		else
		{
			//@warning: can't set bHidden because that would get replicated
			ParticleSystemComponent.DeactivateSystem();
			LifeSpan = ServerLifeSpan;
			SetPhysics(PHYS_None);
		}
	}
}

simulated event ReplicatedEvent(name VarName)
{
	if (VarName == 'NumPoints')
	{
		StartNextPath();
	}
	else
	{
		Super.ReplicatedEvent(VarName);
	}
}

simulated event SetTemplate(ParticleSystem NewTemplate, optional bool bDestroyOnFinish)
{
	Super(Emitter).SetTemplate(NewTemplate, bDestroyOnFinish);
}

simulated function StartNextPath()
{
	local Pawn OwnerPawn;
	local UTWillowWhisp OtherWhisp;

	if (Position == 0 && PlayerController(Owner) != None && PlayerController(Owner).IsLocalPlayerController())
	{
		// destroy old instances
		foreach DynamicActors(class'UTWillowWhisp', OtherWhisp)
		{
			if (OtherWhisp != self && OtherWhisp.Owner == Owner)
			{
				OtherWhisp.Destroy();
			}
		}
	}
	if ( (UTPlayerController(Owner) != None) && UTPlayerController(Owner).bHideObjectivePaths )
	{
		Destroy();
		return;
	}

	if (++Position >= NumPoints)
	{
		LifeSpan = 5.0;
		Velocity = vect(0,0,0);
		ParticleSystemComponent.DeactivateSystem();
		SetPhysics(PHYS_None);
		GotoState('');
	}
	else
	{
		OwnerPawn = (PlayerController(Owner) != None) ? PlayerController(Owner).Pawn : None;
		DesiredRotation = rotator(WayPoints[Position] - Location);
		if (Position == 0 && OwnerPawn != None)
		{
			SetRotation(OwnerPawn.Rotation);
			SetLocation(OwnerPawn.Location + vector(OwnerPawn.Rotation) * 60.0);
		}

		GotoState('Pathing');
	}
}

state Pathing
{
	simulated function Tick(float DeltaTime)
	{
		local float MaxSpeed;
		local Pawn OwnerPawn;

		if ( (UTPlayerController(Owner) != None) && UTPlayerController(Owner).bHideObjectivePaths )
		{
			Destroy();
			return;
		}

		DesiredRotation = rotator(WayPoints[Position] - Location);

		OwnerPawn = (PlayerController(Owner) != None) ? PlayerController(Owner).Pawn : None;
		if (OwnerPawn != None)
		{
			if (VSize(Location - OwnerPawn.Location) < OwnerPawn.GroundSpeed && vector(Rotation) dot vector(OwnerPawn.Rotation) > 0.0)
			{
				// go faster when near owner to get some separation
				MaxSpeed = OwnerPawn.GroundSpeed + 300.0;
			}
			else
			{
				MaxSpeed = VSize(OwnerPawn.Velocity) + 60.0;
				RotationRate = default.RotationRate;
			}
		}
		else
		{
			MaxSpeed = 60.0;
		}

		Velocity = vector(Rotation) * MaxSpeed;
		if (VSize(WayPoints[Position] - Location) < FMax(80.0, VSize(Velocity) * DeltaTime * 3.0))
		{
			StartNextPath();
		}
	}

	simulated function BeginState(name PreviousStateName)
	{
		SetPhysics(PHYS_Projectile);
	}
}

defaultproperties
{
   Position=-1
   EmitterTemplate=ParticleSystem'GamePlaceholders.Effects.WillowWhisp'
   Begin Object Class=ParticleSystemComponent Name=ParticleSystemComponent0 ObjName=ParticleSystemComponent0 Archetype=ParticleSystemComponent'UTGame.Default__UTReplicatedEmitter:ParticleSystemComponent0'
      ObjectArchetype=ParticleSystemComponent'UTGame.Default__UTReplicatedEmitter:ParticleSystemComponent0'
   End Object
   ParticleSystemComponent=ParticleSystemComponent0
   Components(0)=ParticleSystemComponent0
   Physics=PHYS_Projectile
   bOnlyRelevantToOwner=True
   bReplicateMovement=False
   LifeSpan=24.000000
   RotationRate=(Pitch=65535,Yaw=65535,Roll=0)
   Name="Default__UTWillowWhisp"
   ObjectArchetype=UTReplicatedEmitter'UTGame.Default__UTReplicatedEmitter'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:18:36.000 - Creation time: sk 18-3-2018 10:01:30.255 - Created with UnCodeX