## XIII
Class WheelVehicle

source: C:\XIII\XIII\Classes\WheelVehicle.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Decoration
             |
             +--XIII.VehicleDeco
                |
                +--XIII.WheelVehicle

Direct Known Subclasses:ApacheUnderRepairDeco, AmbulanceDeco, DeckTruckDeco, GMCCab01Deco, HummerDeco, JeepDeco, JeepUSDeco, OldsMobileDeco, PickupDeco, PoliceNYDeco, TaxiDeco, TruckDeco, Van01Deco

class WheelVehicle
extends XIII.VehicleDeco

Variables
`WheelVehicle` | `CollisionCopy`
`string` | `CrashLabel`
`/*SmokeEmitterClass,*/` | `ExploEmitterClass`
`vector` | `ExploEmitterOffset`
`int` | `InitialHealth`
`bExplodeIfDead,` | `bDestructible`
`bool` | `bDying`
`Vector` | `vSpeed`

States
Dying

Function Summary
`void` | `PostBeginPlay()`

State Dying Function Summary

Source Code

    00001	class WheelVehicle extends VehicleDeco;
    00002
    00003	VAR bool bDying;
    00004	VAR() bool bExplodeIfDead, bDestructible;
    00005	VAR(Crash) int Health, DamageAmount, DamageRadius;
    00006	VAR int InitialHealth;
    00007	VAR() string CrashLabel;
    00008	VAR(Sound) Sound SoundExplosion;
    00009	VAR(Events) name CrashEvent, DeadEvent;
    00010	VAR Class<Emitter> /*SmokeEmitterClass,*/ ExploEmitterClass;
    00011	VAR vector ExploEmitterOffset;
    00012	VAR	Emitter SmokeEmitter, ExploEmitter;
    00013	VAR Vector vSpeed;
    00014	VAR WheelVehicle CollisionCopy;
    00015
    00016	FUNCTION PostBeginPlay()
    00017	{
    00018		InitialHealth=Health;
    00019		Super.PostBeginPlay();
    00020	}
    00021
    00022	FUNCTION TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType )
    00023	{
    00024		LOCAL Rotator r;
    00025		LOCAL Float f;
    00026
    00027		switch (DamageType)
    00028		{
    00029		case class'DTBladeCut':
    00030		case class'DTStunned':
    00031		case class'DTPierced':
    00032		case class'DTFisted':
    00033			return;
    00034		case class'DTRocketed':
    00035		case class'DTGrenaded':
    00036			Damage*=5;
    00037		}
    00038
    00039		if ( Level.bLonePlayer && bDestructible && !bDying && ( instigatedBy==none || instigatedBy.IsPlayerPawn()) )
    00040		{
    00041			Health= Max(0,Health-Damage);
    00042
    00043			if (Health==0)
    00044			{
    00045				bDying=true;
    00046
    00047				ExploEmitter= spawn(ExploEmitterClass,,,Location+ExploEmitterOffset,Rotation);
    00048
    00049				Instigator = XIIIGameInfo(Level.Game).MapInfo.XIIIPawn;
    00050
    00051				HurtRadius( DamageAmount, DamageRadius, class'DTGrenaded', 0, HitLocation );
    00052
    00053				if ( LinkedTo != none )
    00054					LinkedTo.PlaySound( SoundExplosion );
    00055				else
    00056					PlaySound( SoundExplosion );
    00057
    00058				if ( SmokeEmitter!=none)
    00059					SmokeEmitter.Destroy();
    00060
    00061				GotoState( 'Dying' );
    00062			}
    00063		}
    00064	}
    00065
    00066	STATE Dying
    00067	{
    00068		EVENT BeginState()
    00069		{
    00070			LOCAL int i;
    00071
    00072
    00073			SetCollisionSize( 1, CollisionHeight );
    00074			SetTimer2( 0.25, false );
    00075	// Force Stop wheels
    00076			if( NumParts != 0 )
    00077			{
    00078				for ( i=0; i<MAX_PARTS; i++ )
    00079				{
    00080					if ( VehicleParts[i]!=none && VehicleParts[i].IsA('XIIIWheel') )
    00081					{
    00082						XIIIWheel(VehicleParts[i]).OldLocation=Location;
    00083						XIIIWheel(VehicleParts[i]).Update(0.016);
    00084					}
    00085				}
    00086			}
    00087		}
    00088
    00089		EVENT Timer2()
    00090		{
    00091			SetPhysics( PHYS_Falling );
    00092			Velocity=vect(0,0,300);
    00093			RotationRate=rot(15000,15000,15000);
    00094			DesiredRotation.Yaw = Rotation.Yaw;
    00095			DesiredRotation.Pitch = Rand(2048)-1024;
    00096			DesiredRotation.Roll = Rand(2048)-1024;
    00097			if ( BrokenSM!=none )
    00098				StaticMesh=BrokenSM;
    00099			class'WheelVehicle'.Default.bCollideWorld=false;
    00100			CollisionCopy = Spawn( class'WheelVehicle' );
    00101			class'WheelVehicle'.Default.bCollideWorld=true;
    00102			if ( CollisionCopy == none )
    00103				LOG( "Can't spawn a copy of "$self );
    00104			else
    00105			{
    00106				CollisionCopy.bCollideWorld=true;
    00107				CollisionCopy.StaticMesh = StaticMesh;
    00108				CollisionCopy.bDestructible = false;
    00109				CollisionCopy.SetCollision( true, true, true );
    00110				CollisionCopy.SetDrawType( DT_StaticMesh );
    00111				CollisionCopy.bHidden=true;
    00112				CollisionCopy.RefreshDisplaying();
    00113				SetCollision( false, false, false );
    00114			}
    00115		}
    00116
    00117		EVENT Landed( vector HitNormal )
    00118		{
    00119			LOCAL Rotator r;
    00120
    00121	//		LOG(self@"LANDED"@DesiredRotation@Physics@Velocity@"("@vSize(velocity)@")"@vSize(velocity)>100);
    00122			if ( vSize(velocity)>10 )
    00123			{
    00124				vSpeed = Velocity;
    00125				SetTimer( 0.001, false );
    00126			}
    00127			else
    00128			{
    00129				r.Yaw   = Rotation.Yaw;
    00130				r.Roll  = 0;
    00131				r.PItch = 0;
    00132				SetRotation( r );
    00133				SetPhysics( PHYS_None );
    00134
    00135				if ( CollisionCopy != none )
    00136				{
    00137					CollisionCopy.Destroy();
    00138					SetCollision( true, true, true );
    00139				}
    00140			}
    00141
    00142		}
    00143
    00144		EVENT Timer( )
    00145		{
    00146			SetPhysics( PHYS_Falling );
    00147			Velocity = vSpeed;
    00148			Velocity.Z*=-(0.4*FRand()+0.25);
    00149			DesiredRotation.Yaw = Rotation.Yaw;
    00150			DesiredRotation.Pitch = -(0.5*FRand()+0.5)*DesiredRotation.Pitch;
    00151			DesiredRotation.Roll = -(0.5*FRand()+0.5)*DesiredRotation.Roll;
    00152		}
    00153
    00154		EVENT Tick(float dt)
    00155		{
    00156	//		LOG(")-"@Velocity@"Physics"@Physics);
    00157		}
    00158
    00159		FUNCTION TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType )
    00160		{
    00161		}
    00162	Begin:
    00163	//	SetCollision(false,false,false);
    00164		TriggerEvent( CrashEvent, self, none );
    00165		Sleep( 0.1 );
    00166		TriggerEvent( DeadEvent, self, none );
    00167	//	Destroy( );
    00168	}
    00169
    00170	//	SmokeEmitterClass=class'HelicoHSEmitter'
    00171	STATE() InvisibleUntilTriggered
    00172	{
    00173		EVENT BeginState( )
    00174		{
    00175			DebugLog( "InvisibleUntilTriggered::BeginState" );
    00176			SetTimer( 0.2, false );
    00177		}
    00178
    00179		EVENT Timer( )
    00180		{
    00181			LOCAL int i;
    00182
    00183			DebugLog( "InvisibleUntilTriggered::Timer" );
    00184			if ( LinkedTo!=none )
    00185				Tag=LinkedTo.Tag;
    00186			bHidden=true;
    00187			RefreshDisplaying();
    00188			SetCollision( false, false, false );
    00189			for (i=0;i<MAX_PARTS;i++)
    00190			{
    00191				if ( VehicleParts[i] != None )
    00192				{
    00193					VehicleParts[i].bHidden=bHidden;
    00194					VehicleParts[i].RefreshDisplaying( );
    00195					VehicleParts[i].Disable( 'Tick' );
    00196					VehicleParts[i].SetCollision( false, false, false );
    00197				}
    00198			}
    00199		}
    00200
    00201		EVENT Trigger(actor Other, Pawn EventInstigator)
    00202		{
    00203			DebugLog( "InvisibleUntilTriggered::Trigger" );
    00204			GotoState( '' );
    00205		}
    00206
    00207		EVENT EndState( )
    00208		{
    00209			LOCAL int i;
    00210
    00211			DebugLog( "InvisibleUntilTriggered::EndState" );
    00212			bHidden=false;
    00213			RefreshDisplaying();
    00214			SetCollision( true, true, true );
    00215			for (i=0;i<MAX_PARTS;i++)
    00216			{
    00217				if ( VehicleParts[i] != None )
    00218				{
    00219					VehicleParts[i].bHidden=bHidden;
    00220					VehicleParts[i].RefreshDisplaying( );
    00221					VehicleParts[i].Disable( 'Tick' );
    00222					VehicleParts[i].SetCollision( true, true, true );
    00223				}
    00224			}
    00225			if ( (Shadow!=none) && (XIIIGameInfo(Level.Game).MapInfo != none) )
    00226			{
    00227				Shadow.MaxTraceDistance=XIIIGameInfo(Level.Game).MapInfo.MaxTraceDistance;
    00228				Shadow.ShadowIntensity=XIIIGameInfo(Level.Game).MapInfo.ShadowIntensity;
    00229				Shadow.ShadowMaxDist=XIIIGameInfo(Level.Game).MapInfo.ShadowMaxDist;
    00230				Shadow.ShadowTransDist=XIIIGameInfo(Level.Game).MapInfo.ShadowTransDist;
    00231				Shadow.bShadowIsStatic = ( LinkedTo == none );
    00232			}
    00233		}
    00234
    00235		EVENT Tick(float dt) {}
    00236	}
    00237
    00238
    00239
    00240	defaultproperties
    00241
{ 00242 bExplodeIfDead=True 00243 bDestructible=True 00244 Health=1000 00245 DamageAmount=500 00246 DamageRadius=500 00247 ExploEmitterClass=Class'XIII.LightVehicleExploEmitter' 00248 ExploEmitterOffset=(Z=128.000000) 00249 bOrientOnSlope=False 00250 }

End Source Code