Cogito, ergo sum

UE2:Vehicle (UT2004)

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
UT2004 Object >> Actor >> Pawn >> Vehicle

Contents

Package: 
Engine
Direct subclasses:
ASVehicle, KVehicle, ONSWeaponPawn, SVehicle
This class in other games:
UE2Runtime, U2XMP, UT2003, U2, UDK, UT3

This abstract base class contains gameplay and AI code for vehicles

Properties[edit]

Property group 'Vehicle'[edit]

bDrawDriverInTP[edit]

Type: bool

Whether to draw the driver when in 3rd person mode.

bDrawMeshInFP[edit]

Type: bool

Whether to draw the vehicle mesh when in 1st person mode.

bDriverCollideActors[edit]

Type: bool

"If driver is drawn in vehicle, is Driver.bCollideActors true?", asked the programmer. In fact, this variable is used nowhere else in UnrealScript.

bFPNoZFromCameraPitch[edit]

Type: bool

Ignore any vehicle-space Z due to FPCamViewOffset (so looking up and down doesn't change camera Z rel to vehicle)

bHighScoreKill[edit]

Type: bool

Vehicle is considered important, and awards 5 points upon destruction.

bHUDTrackVehicle[edit]

Type: bool

If true, Vehicle will be tracked on HUD. (This may be used if the vehicle is an Objective in Assault)

bRelativeExitPos[edit]

Type: bool

relative vector to vehicle?

Default value: True

BulletSounds[edit]

Type: array<Sound>

This array stores a row of sounds from which one is chosen randomly to play if the vehicle is hit by a bullet-type weapon. 16 sounds are set in the ONSVehicle class.

bZeroPCRotOnEntry[edit]

Type: bool

If true, set camera rotation to zero on entering vehicle. If false, set it to the vehicle rotation.

Default value: True

DriveAnim[edit]

Type: name

The pose that is used by the driver if he's drawn in the vehicle.

Default value: 'Vehicle_Driving'

DrivePos[edit]

Type: Object.Vector

Position (relative to vehicle) to put player while driving.

Default value:

Member Value
X 0.0
Y 0.0
Z 0.0

DriveRot[edit]

Type: Object.Rotator

Rotation (relative to vehicle) to put driver while driving.

EntryPosition[edit]

Type: Object.Vector

Offset for the entry trigger

Default value:

Member Value
X 0.0
Y 0.0
Z 0.0

EntryRadius[edit]

Type: float

Radius for the entry trigger

Default value: 100.0

ExitPositions[edit]

Type: array<Object.Vector>

Positions (relative to vehicle) to try putting the player when exiting.

Default value:

Member Value
X 0.0
Y 0.0
Z 0.0

FPCamPos[edit]

Type: Object.Vector

Position of camera when driving first person.

FPCamViewOffset[edit]

Type: Object.Vector


HUDOverlayFOV[edit]

Type: float

The FOV with which you will look at the rendered HUDOVerlay actor.

HUDOverlayOffset[edit]

Type: Object.Vector

How far the HUDOverlay actor is away from the perspective of the player.

MaxViewPitch[edit]

Type: int

Maximum amount you can look up and down

Default value: 16000

MaxViewYaw[edit]

Type: int

Maximum amount you can look left and right

Default value: 16000

Rise[edit]

Type: float

Between -1 and 1

SpawnOverlay[edit]

Type: Material

Array size: 2

The texture that is shown on the vehicle when it spawns. The index 0 stores the overlay texture for the red team, 1 for the blue team.

Steering[edit]

Type: float

between -1 and 1

Team[edit]

Type: byte

To which team does this vehicle belong. 0 = red; 1 = blue; 255 = neutral/none.

Default value: 255

Throttle[edit]

Type: float

between -1 and 1

TPCamDistRange[edit]

Type: Object.Range

How close can the third person camera be zoomed to the vehicle before it switches to first person cam and how far can it be zoomed away from the vehicle.

Default value:

Member Value
Max 1500.0
Min 50.0

TPCamLookat[edit]

Type: Object.Vector

Look at location in vehicle space

Default value:

Member Value
X -100.0
Y 0.0
Z 100.0

TPCamWorldOffset[edit]

Type: Object.Vector

Applied in world space after vehicle transform.

Default value:

Member Value
X 0.0
Y 0.0
Z 0.0

WaterDamage[edit]

Type: float

How much damage does the vehicle take per second if it's in a WaterVolume with bDamageVehicle = true.

Internal variables[edit]

See Vehicle internal variables.

Default values[edit]

Property Value
bCanBeBaseForPawns True
bDontPossess True
bForceSkelUpdate True
bUseCompressedPosition False
CollisionHeight 50.0
CollisionRadius 120.0
CrouchedPct 1.0
LandMovementState 'PlayerDriving'
NetPriority 1.0
NetUpdateFrequency 4.0
SightRadius 15000.0
WalkingPct 1.0

Structs[edit]

SVehicleIcon[edit]

Modifiers: native

Material Material 
float
float
float SizeX 
float SizeY 
bool bIsGreyScale 

Functions[edit]

Static functions[edit]

StaticPrecache[edit]

static function StaticPrecache (LevelInfo L)

Overrides: Pawn.StaticPrecache


Native code[edit]

Team beacon drawing[edit]

void AVehicle::PostRender(FLevelSceneNode* SceneNode, FRenderInterface* RI)
{
	guard(AVehicle::PostRender);
 
	// Render team beacon
	if ( !SceneNode || !SceneNode->Viewport || !SceneNode->Viewport->Actor )
		return;
 
	if ( bScriptPostRender )
	{
		FVector camLoc = SceneNode->WorldToCamera.TransformFVector(Location + FVector(0.f,0.f,CollisionHeight));
		FPlane  screenLoc = SceneNode->Project(SceneNode->CameraToWorld.TransformFVector(camLoc));
		screenLoc.X = (SceneNode->Viewport->Canvas->ClipX * 0.5f * (screenLoc.X + 1.f));
		screenLoc.Y = (SceneNode->Viewport->Canvas->ClipY * 0.5f * (-screenLoc.Y + 1.f));
		eventPostRender2D(SceneNode->Viewport->Canvas,screenLoc.X, screenLoc.Y);
		return;
	}
	if ( bNoTeamBeacon || ((SceneNode->Viewport->Actor->ViewTarget == this) && (SceneNode->Viewport->Actor->Pawn == this)) )
		return;
 
	APlayerController* pc = SceneNode->Viewport->Actor;
	UBOOL bSpectating = pc->PlayerReplicationInfo ? (pc->PlayerReplicationInfo->bOnlySpectator && !pc->bHideSpectatorBeacons) : false;
 
	INT playerTeamIndex   = -1;
 
	// Draw 'No Entry' indicator.
	if ( !bSpectating && !SceneNode->Viewport->Actor->bHideVehicleNoEntryIndicator )
	{
		if (pc->PlayerReplicationInfo && pc->PlayerReplicationInfo->Team)
			playerTeamIndex = pc->PlayerReplicationInfo->Team->TeamIndex;
 
		if (playerTeamIndex < 0 || playerTeamIndex > 1)
			return;
 
		if ( bTeamLocked && (playerTeamIndex != Team) && !PlayerReplicationInfo )
		{
			FLOAT actorDist = SceneNode->WorldToScreen.TransformFVector(Location).Z;
 
			if ( (actorDist < 0.f) || (actorDist > 2.f * pc->TeamBeaconPlayerInfoMaxDist) || !NoEntryTexture )
				return;
 
			FCheckResult Hit(1.f);
			GetLevel()->SingleLineCheck( Hit, this, Location, SceneNode->ViewOrigin, TRACE_World|TRACE_StopAtFirstHit );
			if ( Hit.Actor )
			{
				GetLevel()->SingleLineCheck( Hit, this, Location + FVector(0.f,0.f,0.5f*CollisionHeight), SceneNode->ViewOrigin, TRACE_World|TRACE_StopAtFirstHit );
				if ( Hit.Actor )
					return;
			}
			GetLevel()->SingleLineCheck( Hit, pc->Pawn, Location, SceneNode->ViewOrigin, TRACE_Pawns );
			if ( Hit.Actor && (Hit.Actor != this) && !Hit.Actor->bWorldGeometry )
			{
				if ( Hit.Actor->Physics == PHYS_Karma )
					return;
				FVector Projected = (Hit.Actor->Location - Hit.Location);
				FVector ViewDir = (Hit.Actor->Location - SceneNode->ViewOrigin).SafeNormal();
				Projected = Projected - ViewDir * (ViewDir | Projected);
				if ( Abs(Projected.Z) < 0.8f * Hit.Actor->CollisionHeight )
					return;
				Projected.Z = 0.f;
				if ( Projected.SizeSquared() < 0.25f * Hit.Actor->CollisionRadius * Hit.Actor->CollisionRadius )
					return;
			}
 
			// draw locked symbol
			FVector camLoc = SceneNode->WorldToCamera.TransformFVector(Location);
			FPlane  screenLoc = SceneNode->Project(SceneNode->CameraToWorld.TransformFVector(camLoc));
			SceneNode->Viewport->Canvas->Style = STY_AlphaZ;
			FLOAT   xscale = ::Clamp( (2.f*pc->TeamBeaconPlayerInfoMaxDist - actorDist)/(2.f*pc->TeamBeaconPlayerInfoMaxDist), 0.55f, 1.f);
			xscale = xscale * xscale;
			screenLoc.X = (SceneNode->Viewport->Canvas->ClipX * 0.5f * (screenLoc.X + 1.f)) - 0.5*NoEntryTexture->USize*xscale;
			screenLoc.Y = (SceneNode->Viewport->Canvas->ClipY * 0.5f * (-screenLoc.Y + 1.f)) - 0.5*NoEntryTexture->VSize*xscale;
 
			SceneNode->Viewport->Canvas->DrawTile(
				NoEntryTexture,
				screenLoc.X, 
				screenLoc.Y, 
				NoEntryTexture->USize*xscale,
				NoEntryTexture->VSize*xscale,
				0.f, 
				0.f, 
				NoEntryTexture->USize, 
				NoEntryTexture->VSize,
				0.f,
				FPlane(1.f,0.f,0.f,1.f),
				FPlane(0.0f,0.0f,0.0f,0.0f));
			return;
		}
	}
 
	INT teamIndex = -1;
 
	if (PlayerReplicationInfo && PlayerReplicationInfo->Team)
		teamIndex = PlayerReplicationInfo->Team->TeamIndex;
	else
		teamIndex = Team;
 
	if ( teamIndex == -1 )
		return;
	if ( !bSpectating && (teamIndex != playerTeamIndex) )
		return;
	UTexture* teamBeacon = TeamBeaconTexture;
	UMaterial* teamBeaconBorder = TeamBeaconBorderMaterial;
 
	if ( !teamBeacon )
	{
		if ( !bDrawDriverInTP || (Driver && ((Location - SceneNode->ViewOrigin).SizeSquared() > Square(Driver->CullDistance))) )
			Super::PostRender(SceneNode,RI);
		return;
	}
 
	FLOAT actorDist = pc->FOVBias * SceneNode->WorldToScreen.TransformFVector(Location).Z;
	FLOAT ScaledDist = pc->TeamBeaconMaxDist * ::Clamp(0.04f * CollisionRadius,1.f,3.f);
 
	if ( (actorDist < 0.f) || (actorDist > ScaledDist) )
		return;
 
	if (!pc->LineOfSightTo(this))
		return;
 
	FPlane color = (teamIndex == 0) ? FPlane(1.f,0.25f,0.25f,1.f) : FPlane(0.25f,0.35f,1.f,1.f);
	if ( teamIndex > 1 )
		color = (teamIndex == 2) ? FPlane(0.f,1.f,0.25f,1.f) : FPlane(1.f,1.f,0.f,1.f);
	FVector camLoc = SceneNode->WorldToCamera.TransformFVector(Location+FVector(0.0f,0.0f,1.75f * CollisionHeight));
	FPlane  screenLoc = SceneNode->Project(SceneNode->CameraToWorld.TransformFVector(camLoc));
 
	SceneNode->Viewport->Canvas->Style = STY_AlphaZ;
	FLOAT   xscale = ::Clamp( (pc->TeamBeaconMaxDist - actorDist)/pc->TeamBeaconMaxDist, 0.7f, 1.f);
	xscale = xscale * xscale * 0.5f;
	if ( actorDist < 10.f*CollisionRadius)
		xscale *= 3.f * ::Max( 0.333f, (10.f*CollisionRadius - actorDist)/(10.f*CollisionRadius));
	else if ( actorDist > 1.5f * pc->TeamBeaconMaxDist )
		xscale *= ::Max( 0.5f, (ScaledDist - actorDist)/(ScaledDist - 1.5f * pc->TeamBeaconMaxDist));
 
	FLOAT   yscale = 0.25f * xscale;
	screenLoc.X = (SceneNode->Viewport->Canvas->ClipX * 0.5f * (screenLoc.X + 1.f)) - 0.5*teamBeacon->USize*xscale;
	screenLoc.Y = (SceneNode->Viewport->Canvas->ClipY * 0.5f * (-screenLoc.Y + 1.f)) - 0.5*teamBeacon->VSize*xscale;
 
	if ( !bHUDTrackVehicle )
	{
		if ( teamBeaconBorder )
		{
			SceneNode->Viewport->Canvas->DrawTile(
				teamBeaconBorder,
				screenLoc.X, 
				screenLoc.Y, 
				teamBeacon->USize*xscale,
				teamBeacon->VSize*yscale,
				0.f, 
				0.f, 
				teamBeacon->USize, 
				teamBeacon->VSize,
				0.f,
				FPlane(1.f,1.f,1.f,1.f),
				FPlane(0.0f,0.0f,0.0f,0.0f));
		}
 
		if ( teamBeacon )
		{
			FPlane HealthColor;
			if (Health / HealthMax > 0.5)
			{
				HealthColor = FPlane(::Clamp(1.f - (HealthMax - (HealthMax - Health) * 2)/HealthMax,0.f,1.f),
					1.f,
					0.f,
					1.f);
			}
			else
			{
				HealthColor = FPlane(1.f,
					::Clamp(2.f*Health/HealthMax,0.f,1.f),
					0.f,
					1.f);
			}
			SceneNode->Viewport->Canvas->DrawTile(
				teamBeacon,
				screenLoc.X, 
				screenLoc.Y, 
				teamBeacon->USize*xscale * Health/HealthMax,
				teamBeacon->VSize*yscale,
				0.f, 
				0.f, 
				teamBeacon->USize, 
				teamBeacon->VSize,
				0.f,
				HealthColor,
				FPlane(0.0f,0.0f,0.0f,0.0f));
		}
	}
 
	if ( PlayerReplicationInfo && (!bDrawDriverInTP  || (Driver && ((Location - SceneNode->ViewOrigin).SizeSquared() > Square(Driver->CullDistance)))) )
	{
		FLOAT xL, yL;
		FString info;
 
		UTexture* PCteamBeacon = pc->TeamBeaconTexture;
		if ( PCteamBeacon )
		{
			//FLOAT   xscale = Clamp(0.28f * (ScaledDist - actorDist)/ScaledDist,0.1f, 0.25f);
			if ( pc->myHUD && pc->myHUD->PortraitPRI && (pc->myHUD->PortraitPRI ==PlayerReplicationInfo) && pc->SpeakingBeaconTexture )
			{
				teamBeacon = pc->SpeakingBeaconTexture;
				xscale = 3.f * Clamp(0.28f * (ScaledDist - actorDist)/ScaledDist,0.1f, 0.25f);;
			}
			screenLoc.X -= teamBeacon->USize*xscale;
			screenLoc.Y -= 0.5*teamBeacon->VSize*xscale;
			SceneNode->Viewport->Canvas->Style = STY_AlphaZ;
 
			SceneNode->Viewport->Canvas->DrawTile(
				PCteamBeacon,
				screenLoc.X, 
				screenLoc.Y, 
				PCteamBeacon->USize*xscale,
				PCteamBeacon->VSize*xscale,
				0.f, 
				0.f, 
				PCteamBeacon->USize, 
				PCteamBeacon->VSize,
				0.f,
				color,
				FPlane(0.0f,0.0f,0.0f,0.0f));
		}
		if ( !GIsPixomatic && (actorDist < 2.f*pc->TeamBeaconPlayerInfoMaxDist) && (SceneNode->Viewport->Canvas->ClipX > 600) )
		{
			if ( PlayerReplicationInfo->bBot )
				info +=(PlayerReplicationInfo->eventGetNameCallSign());
			else
				info +=(PlayerReplicationInfo->PlayerName);
			SceneNode->Viewport->Canvas->ClippedStrLen(
				SceneNode->Viewport->Canvas->SmallFont,
				1.f, 1.f, xL, yL, *info);
 
			INT index = pc->PlayerNameArray.AddZeroed();
			pc->PlayerNameArray(index).mInfo  = info;
			pc->PlayerNameArray(index).mColor = color;
			pc->PlayerNameArray(index).mXPos  = screenLoc.X;
			pc->PlayerNameArray(index).mYPos  = screenLoc.Y - yL;
		}
	}
	unguard;
}

Events[edit]

Destroyed[edit]

simulated event Destroyed ()

Overrides: Pawn.Destroyed

Vehicle notifies the ParentFactory of it's death, deletes it's ShadowProjector and Controllers of auto turrets and removes itself from the Level.Game.VehicleList

DrivingStatusChanged[edit]

simulated event DrivingStatusChanged ()

Vehicle adjust it's bDropDetail value and enables the Tick if it's driven (or disables it if there is no driver anymore)

EncroachedBy[edit]

event EncroachedBy (Actor Other)

Overrides: Pawn.EncroachedBy

Overrides the super function with an empty one because vehicles can't get telefragged.

EncroachingOn[edit]

event bool EncroachingOn (Actor Other)

Overrides: Pawn.EncroachingOn

Called when the vehicle couldn't move a pawn out of it's way. If the pawn isn't a vehicle, then it will be crunched with a lot of damage, no matter if it's an enemy or not. The vehicle basically had no other choice.

IsVehicleEmpty[edit]

event bool IsVehicleEmpty ()

True if the vehicle has no driver.

KDriverLeave[edit]

event bool KDriverLeave (bool bForceLeave)

Called by the driver who wants to get out. The vehicle tries to find a good exit position (if it finds none, the driver will stay inside). Then it places the driver outside, assign the Controller which was on the vehicle to the driver, gives the driver his flag if he carried it inside the vehicle and pulls the brakes on the vehicle before the driver gets out.

LockOnWarning[edit]

event LockOnWarning ()

Displays a message for the player who tries to enter the locked vehicle. Repeats the message after a certain time if the player still doesn't get his hands off.

NeedsFlip[edit]

event bool NeedsFlip ()

True, if the vehicle lies on it's back. This also takes the gravity direction of the map into account.

NotifyEnemyLockedOn[edit]

event NotifyEnemyLockedOn ()

Sets bEnemyLockedOn to True.

NotifyEnemyLostLock[edit]

event NotifyEnemyLostLock ()

Sets bEnemyLockedOn to False.

PlayDying[edit]

simulated event PlayDying (class<DamageTypeDamageType, Object.Vector HitLoc)

Overrides: Pawn.PlayDying

Empty.

PostBeginPlay[edit]

simulated event PostBeginPlay ()

Overrides: Pawn.PostBeginPlay

Assigns a shadow to the vehicle and sets a Controller if the vehicle is an auto turret.

PreBeginPlay[edit]

event PreBeginPlay ()

Overrides: Pawn.PreBeginPlay

Deletes the vehicle if no vehicles are allowed in the current gametype.

RanInto[edit]

event RanInto (Actor Other)

Overrides: Actor.RanInto

Called for encroaching actors which successfully moved the other actor out of the way. Will move the encroaching non-vehicle pawn out of the way at low speed or deal a lot of damage at higher speed.

SetAnimAction[edit]

simulated event SetAnimAction (name NewAction)

Overrides: Pawn.SetAnimAction

Calls the SetAnimAction of the driver and delegates the NewAction to it.

SetInitialState[edit]

simulated event SetInitialState ()

Overrides: Actor.SetInitialState

Disables Tick at the beginning.

SetWheelsScale[edit]

simulated event SetWheelsScale (float NewScale)

Sets the WheelScale. Obviously.

Stalled[edit]

simulated event Stalled ()

Sets bStalled to True if the vehicle is above the level's StallZ. A vehicle with bStalled can't apply acceleration any more.

TakeDamage[edit]

event TakeDamage (int Damage, Pawn instigatedBy, Object.Vector hitlocation, Object.Vector momentum, class<DamageTypedamageType)

Overrides: Pawn.TakeDamage

Takes the vehicle's SpawnProtection into account and adjusts the caused damaged according to the damage type's VehicleDamageScaling and VehicleMomentumScaling. Also hurts the driver if that option is enables and kills or ejects him if the vehicle is killed.

TakeWaterDamage[edit]

event TakeWaterDamage (float DeltaTime)

Deals the WaterDamage to the vehicle. Also spawns some splashes if the vehicle is fast enough.

TeamChanged[edit]

simulated event TeamChanged ()

Empty.

UnStalled[edit]

simulated event UnStalled ()

Sets bStalled to False if the vehicle fell below the StallZ again.

UpdateEyeHeight[edit]

event UpdateEyeHeight (float DeltaTime)

Overrides: Pawn.UpdateEyeHeight


UpdateTiltForceFeedback[edit]

simulated event UpdateTiltForceFeedback ()


UsedBy[edit]

event UsedBy (Pawn user)

Overrides: Actor.UsedBy

Someone pressed the Use-button on this vehicle, try to let him drive if the driver seat isn't taken already.

VehicleLocked[edit]

event VehicleLocked (Pawn P)

Pawn tried to enter the vehicle, but it's locked. So call an event in C++ instead.

VerifyLock[edit]

event bool VerifyLock (Actor Aggressor, out Actor NewTarget)

Used to override locking actors. Returns who the aggressor really should lock on to.

Other instance functions[edit]

See Vehicle instance functions.

States[edit]

Deployed[edit]

Has no state code, only state functions.

Deployed.VehicleCeaseFire[edit]

function VehicleCeaseFire (bool bWasAltFire)

Overrides: VehicleCeaseFire (global)

Calls the global version of this function.

Deployed.VehicleFire[edit]

function VehicleFire (bool bWasAltFire)

Overrides: VehicleFire (global)

Calls the global version of this function.

UnDeployed[edit]

Has no state code, only state functions.

UnDeployed.VehicleCeaseFire[edit]

function VehicleCeaseFire (bool bWasAltFire)

Overrides: VehicleCeaseFire (global)

Calls the global version of this function.

UnDeployed.VehicleFire[edit]

function VehicleFire (bool bWasAltFire)

Overrides: VehicleFire (global)

Calls the global version of this function.