UE2:Vehicle (UT2004)
- Package:
- Engine
- Direct subclasses:
- ASVehicle, KVehicle, ONSWeaponPawn, SVehicle
- This class in other games:
Please help improve this article or section by expanding it. |
This abstract base class contains gameplay and AI code for vehicles
Properties
Property group 'Vehicle'
bDrawDriverInTP
Type: bool
Whether to draw the driver when in 3rd person mode.
bDrawMeshInFP
Type: bool
Whether to draw the vehicle mesh when in 1st person mode.
bDriverCollideActors
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
Type: bool
Ignore any vehicle-space Z due to FPCamViewOffset (so looking up and down doesn't change camera Z rel to vehicle)
bHighScoreKill
Type: bool
Vehicle is considered important, and awards 5 points upon destruction.
bHUDTrackVehicle
Type: bool
If true, Vehicle will be tracked on HUD. (This may be used if the vehicle is an Objective in Assault)
bRelativeExitPos
Type: bool
relative vector to vehicle?
Default value: True
BulletSounds
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
Type: bool
If true, set camera rotation to zero on entering vehicle. If false, set it to the vehicle rotation.
Default value: True
DriveAnim
Type: name
The pose that is used by the driver if he's drawn in the vehicle.
Default value: 'Vehicle_Driving'
DrivePos
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
Type: Object.Rotator
Rotation (relative to vehicle) to put driver while driving.
EntryPosition
Type: Object.Vector
Offset for the entry trigger
Default value:
Member | Value |
---|---|
X | 0.0 |
Y | 0.0 |
Z | 0.0 |
EntryRadius
Type: float
Radius for the entry trigger
Default value: 100.0
ExitPositions
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
Type: Object.Vector
Position of camera when driving first person.
FPCamViewOffset
Type: Object.Vector
HUDOverlayFOV
Type: float
The FOV with which you will look at the rendered HUDOVerlay actor.
HUDOverlayOffset
Type: Object.Vector
How far the HUDOverlay actor is away from the perspective of the player.
MaxViewPitch
Type: int
Maximum amount you can look up and down
Default value: 16000
MaxViewYaw
Type: int
Maximum amount you can look left and right
Default value: 16000
Rise
Type: float
Between -1 and 1
SpawnOverlay
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
Type: float
between -1 and 1
Team
Type: byte
To which team does this vehicle belong. 0 = red; 1 = blue; 255 = neutral/none.
Default value: 255
Throttle
Type: float
between -1 and 1
TPCamDistRange
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
Type: Object.Vector
Look at location in vehicle space
Default value:
Member | Value |
---|---|
X | -100.0 |
Y | 0.0 |
Z | 100.0 |
TPCamWorldOffset
Type: Object.Vector
Applied in world space after vehicle transform.
Default value:
Member | Value |
---|---|
X | 0.0 |
Y | 0.0 |
Z | 0.0 |
WaterDamage
Type: float
How much damage does the vehicle take per second if it's in a WaterVolume with bDamageVehicle = true.
Internal variables
See Vehicle internal variables.
Default values
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
SVehicleIcon
Modifiers: native
Functions
Static functions
StaticPrecache
Overrides: Pawn.StaticPrecache
Native code
Team beacon drawing
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
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
Vehicle adjust it's bDropDetail value and enables the Tick if it's driven (or disables it if there is no driver anymore)
EncroachedBy
Overrides: Pawn.EncroachedBy
Overrides the super function with an empty one because vehicles can't get telefragged.
EncroachingOn
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
True if the vehicle has no driver.
KDriverLeave
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
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
True, if the vehicle lies on it's back. This also takes the gravity direction of the map into account.
NotifyEnemyLockedOn
Sets bEnemyLockedOn to True.
NotifyEnemyLostLock
Sets bEnemyLockedOn to False.
PlayDying
Overrides: Pawn.PlayDying
Empty.
PostBeginPlay
Overrides: Pawn.PostBeginPlay
Assigns a shadow to the vehicle and sets a Controller if the vehicle is an auto turret.
PreBeginPlay
Overrides: Pawn.PreBeginPlay
Deletes the vehicle if no vehicles are allowed in the current gametype.
RanInto
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
Overrides: Pawn.SetAnimAction
Calls the SetAnimAction of the driver and delegates the NewAction to it.
SetInitialState
Overrides: Actor.SetInitialState
Disables Tick at the beginning.
SetWheelsScale
Sets the WheelScale. Obviously.
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
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
Deals the WaterDamage to the vehicle. Also spawns some splashes if the vehicle is fast enough.
TeamChanged
Empty.
UnStalled
Sets bStalled to False if the vehicle fell below the StallZ again.
UpdateEyeHeight
Overrides: Pawn.UpdateEyeHeight
UpdateTiltForceFeedback
UsedBy
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
Pawn tried to enter the vehicle, but it's locked. So call an event in C++ instead.
VerifyLock
Used to override locking actors. Returns who the aggressor really should lock on to.
Other instance functions
See Vehicle instance functions.
States
Deployed
Has no state code, only state functions.
Deployed.VehicleCeaseFire
Overrides: VehicleCeaseFire (global)
Calls the global version of this function.
Deployed.VehicleFire
Overrides: VehicleFire (global)
Calls the global version of this function.
UnDeployed
Has no state code, only state functions.
UnDeployed.VehicleCeaseFire
Overrides: VehicleCeaseFire (global)
Calls the global version of this function.
UnDeployed.VehicleFire
Overrides: VehicleFire (global)
Calls the global version of this function.