Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 |
/** * * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved. */ class UTWalkerBody extends Actor native(Vehicle) abstract notplaceable; // 3 legged walkers, by default const NUM_WALKER_LEGS = 3; enum EWalkerLegID { WalkerLeg_Rear, WalkerLeg_FrontLeft, WalkerLeg_FrontRight }; /** Skel mesh for the legs. */ var() /*const*/ editconst SkeletalMeshComponent SkeletalMeshComponent; /** Refs to shoulder lookat skelcontrols for each leg */ var protected transient SkelControlLookat ShoulderSkelControl[NUM_WALKER_LEGS]; /** Names for the shoulder skelcontrol nodes for each leg (from the animtree) */ var protected const Name ShoulderSkelControlName[NUM_WALKER_LEGS]; /** If TRUE for corresponding foot, walking/stepping code will ignore that leg */ var() byte IgnoreFoot[NUM_WALKER_LEGS]; /** Handles used to move the walker feet around. */ var() UTWalkerStepHandle FootConstraints[NUM_WALKER_LEGS]; /** world time to advance to the next phase of the step - experimental walker leg code */ var float NextStepStageTime[NUM_WALKER_LEGS]; /** Time, in seconds, that each step stage lasts. */ var() const array<float> StepStageTimes; /** which stage the step is in for each leg - experimental walker leg code */ var protected int StepStage[NUM_WALKER_LEGS]; /** used to play water effects when feet enter/exit water */ var byte FootInWater[NUM_WALKER_LEGS]; var ParticleSystem FootWaterEffect; /** Min dist trigger to make foot a possible candidate for next step */ var() float MinStepDist; /** Max leg extension */ var() float MaxLegReach; /** Factor in range [0..1]. 0 means no leg spread, 1 means legs are spread as far as possible. */ var() float LegSpreadFactor; var() float CustomGravityScale; var() float LandedFootDistSq; /** How far foot should embed into ground. */ var() protected const float FootEmbedDistance; /** Bone names for this walker */ var const name FootBoneName[NUM_WALKER_LEGS]; var const name ShoulderBoneName[NUM_WALKER_LEGS]; var const name BodyBoneName; /** Ref to the walker vehicle that we are attached to. */ var transient UTVehicle_Walker WalkerVehicle; var protected const bool bHasCrouchMode; var bool bIsDead; /** Where the feet are right now */ var vector CurrentFootPosition[NUM_WALKER_LEGS]; var array<MaterialImpactEffect> FootStepEffects; var ParticleSystemComponent FootStepParticles[NUM_WALKER_LEGS]; /** Store indices into the legs array, used to map from rear/left/right leg designations to the model's leg indices. Indexed by LegID. */ var transient int LegMapping[EWalkerLegID.EnumCount]; /** Base directions from the walker center for the legs to point, in walker-local space. Indexed by LegID. */ var protected const vector BaseLegDirLocal[EWalkerLegID.EnumCount]; /** * Scalar to control how much velocity to add to the desired foot positions. Indexed by LegID. * This effectively controls how far ahead of the walker the legs will try to reach while the walker * is moving. */ var() const float FootPosVelAdjScale[EWalkerLegID.EnumCount]; /** Names of the anim nodes for playing the step anim for a leg. Used to fill in FootStepAnimNode array. */ var protected const Name FootStepAnimNodeName[NUM_WALKER_LEGS]; /** Refs to AnimNodes used for playing step animations */ var protected AnimNode FootStepAnimNode[NUM_WALKER_LEGS]; /** How far above the current foot position to begin interpolating towards. */ var() protected const float FootStepStartLift; /** How far above the desired foot position to end the foot step interpolation */ var() protected const float FootStepEndLift; struct native WalkerLegStepAnimData { /** Where foot wants to be. */ var vector DesiredFootPosition; /** Normal of the surface at the desired foot position. */ var vector DesiredFootPosNormal; /** Physical material at the DesiredFootPosition */ var PhysicalMaterial DesiredFootPosPhysMaterial; /** True if we don't have a valid desired foot position for this leg. */ var bool bNoValidFootHold; }; /** Indexed by LegID. */ var protected WalkerLegStepAnimData StepAnimData[EWalkerLegID.EnumCount]; /** keeps track of previous leg locations */ var protected vector PreviousTraceSeedLocation[NUM_WALKER_LEGS]; /** The walker legs's light environment */ var DynamicLightEnvironmentComponent LegLightEnvironment; var float MaxFootStepEffectDist; // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) function PostBeginPlay() { local int Idx; super.PostBeginPlay(); // make sure the rb is awake SkeletalMeshComponent.WakeRigidBody(); for (Idx=0; Idx<NUM_WALKER_LEGS; ++Idx) { // cache refs to footstep anims FootStepAnimNode[Idx] = SkeletalMeshComponent.FindAnimNode(FootStepAnimNodeName[Idx]); // cache refs to skel controls ShoulderSkelControl[Idx] = SkelControlLookAt(SkeletalMeshComponent.FindSkelControl(ShoulderSkelControlName[Idx])); if (ShoulderSkelControl[Idx] != None) { // turn it on ShoulderSkelControl[Idx].SetSkelControlActive(TRUE); } } } simulated function UpdateShadowSettings(bool bWantShadow) { local bool bNewCastShadow, bNewCastDynamicShadow; if (SkeletalMeshComponent != None) { bNewCastShadow = default.SkeletalMeshComponent.CastShadow && bWantShadow; bNewCastDynamicShadow = default.SkeletalMeshComponent.bCastDynamicShadow && bWantShadow; if (bNewCastShadow != SkeletalMeshComponent.CastShadow || bNewCastDynamicShadow != SkeletalMeshComponent.bCastDynamicShadow) { SkeletalMeshComponent.CastShadow = bNewCastShadow; SkeletalMeshComponent.bCastDynamicShadow = bNewCastDynamicShadow; // defer if we can do so without it being noticeable if (LastRenderTime < WorldInfo.TimeSeconds - 1.0) { SetTimer(0.1 + FRand() * 0.5, false, 'ReattachMesh'); } else { ReattachMesh(); } } } } /** reattaches the mesh component, because settings were updated */ simulated function ReattachMesh() { DetachComponent(SkeletalMeshComponent); AttachComponent(SkeletalMeshComponent); } /* epic =============================================== * ::StopsProjectile() * * returns true if Projectiles should call ProcessTouch() when they touch this actor */ simulated function bool StopsProjectile(Projectile P) { // Don't block projectiles fired from this vehicle return (P.Instigator != WalkerVehicle) && (bProjTarget || bBlockActors); } /** Called once to set up legs. */ native function InitFeet(); /** Called on landing to reestablish a foothold */ native function InitFeetOnLanding(); function SetWalkerVehicle(UTVehicle_Walker V) { WalkerVehicle = V; SkeletalMeshComponent.SetShadowParent(WalkerVehicle.Mesh); SkeletalMeshComponent.SetLightEnvironment(LegLightEnvironment); InitFeet(); } event PlayFootStep(int LegIdx) { local AudioComponent AC; local UTPhysicalMaterialProperty PhysicalProperty; local int EffectIndex; local vector HitLoc,HitNorm,TraceLength; local TraceHitInfo HitInfo; if (FootStepEffects.Length == 0) { return; } // figure out what we landed on TraceLength = vector(QuatToRotator(SkeletalMeshComponent.GetBoneQuaternion(FootBoneName[LegIdx])))*5.0; //Trace(HitLoc,HitNorm, CurrentFootPosition[LegIdx]+TraceLength,CurrentFootPosition[LegIdx],true,,HitInfo); Trace(HitLoc,HitNorm, CurrentFootPosition[LegIdx]-TraceLength,CurrentFootPosition[LegIdx]-TraceLength*4.0,true,,HitInfo); if(HitInfo.PhysMaterial != none) { PhysicalProperty = UTPhysicalMaterialProperty(HitInfo.PhysMaterial.GetPhysicalMaterialProperty(class'UTPhysicalMaterialProperty')); //(StepAnimData[LegIdx].DesiredFootPosPhysMaterial.GetPhysicalMaterialProperty(class'UTPhysicalMaterialProperty')); } if (PhysicalProperty != None) { EffectIndex = FootStepEffects.Find('MaterialType', PhysicalProperty.MaterialType); if (EffectIndex == INDEX_NONE) { EffectIndex = 0; } // Footstep particle if (FootStepEffects[EffectIndex].ParticleTemplate != None && EffectIsRelevant(Location, false)) { if (FootStepParticles[LegIdx] == None) { FootStepParticles[LegIdx] = new(self) class'UTParticleSystemComponent'; FootStepParticles[LegIdx].bAutoActivate = false; SkeletalMeshComponent.AttachComponent(FootStepParticles[LegIdx], FootBoneName[LegIdx]); } FootStepParticles[LegIdx].SetTemplate(FootStepEffects[EffectIndex].ParticleTemplate); FootStepParticles[LegIdx].ActivateSystem(); } } AC = WorldInfo.CreateAudioComponent(FootStepEffects[EffectIndex].Sound, false, true); if (AC != None) { AC.bUseOwnerLocation = false; // play it closer to the player if he's controlling the walker AC.Location = (PlayerController(WalkerVehicle.Controller) != None) ? 0.5 * (Location + CurrentFootPosition[LegIdx]) : CurrentFootPosition[LegIdx]; AC.bAutoDestroy = true; AC.Play(); } WalkerVehicle.TookStep(LegIdx); } event SpawnFootWaterEffect(int LegIdx) { if (FootWaterEffect != None) { WorldInfo.MyEmitterPool.SpawnEmitter(FootWaterEffect, CurrentFootPosition[LegIdx]); } } /** * Default behavior when shot is to apply an impulse and kick the KActor. */ event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser) { local vector ApplyImpulse; if (damageType.default.KDamageImpulse > 0 ) { if ( VSize(momentum) < 0.001 ) { LogInternal("Zero momentum to KActor.TakeDamage"); return; } // Make sure we have a valid TraceHitInfo with our SkeletalMesh // we need a bone to apply proper impulse CheckHitInfo( HitInfo, SkeletalMeshComponent, Normal(Momentum), hitlocation ); ApplyImpulse = Normal(momentum) * damageType.default.KDamageImpulse; if ( HitInfo.HitComponent != None ) { HitInfo.HitComponent.AddImpulse(ApplyImpulse, HitLocation, HitInfo.BoneName); } } } function PlayDying() { local int i; Lifespan = 8.0; CustomGravityScale = 1.5; bCollideWorld = true; bIsDead = true; // clear all constraints for ( i=0; i<3; i++ ) { FootConstraints[i].ReleaseComponent(); } SkeletalMeshComponent.SetTraceBlocking(true, false); SkeletalMeshComponent.SetBlockRigidBody(true); SkeletalMeshComponent.SetShadowParent(None); GotoState('DyingVehicle'); } function AddVelocity( vector NewVelocity, vector HitLocation,class<DamageType> DamageType, optional TraceHitInfo HitInfo ) { if ( !IsZero(NewVelocity) ) { if (Location.Z > WorldInfo.StallZ) { NewVelocity.Z = FMin(NewVelocity.Z, 0); } NewVelocity = DamageType.Default.VehicleMomentumScaling * DamageType.Default.KDamageImpulse * Normal(NewVelocity); SkeletalMeshComponent.AddImpulse(NewVelocity, HitLocation); } } state DyingVehicle { event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser) { if ( DamageType == None ) return; AddVelocity(Momentum, HitLocation, DamageType, HitInfo); } } /** cause a single step, used for debugging */ native function DoTestStep(int LegIdx, float Mag); /** NOTE: this is actually what changes the colors on the PowerOrb on the legs of the Walker **/ simulated function TeamChanged() { local MaterialInterface NewMaterial; NewMaterial = WalkerVehicle.Mesh.GetMaterial(0); SkeletalMeshComponent.SetMaterial( 0, NewMaterial ); NewMaterial = WalkerVehicle.Mesh.GetMaterial(1); SkeletalMeshComponent.SetMaterial( 1, NewMaterial ); } /** NOTE: this is actually what changes the colors on the PowerOrb on the legs of the Walker **/ simulated function SetBurnOut() { local int TeamNum; local BurnOutDatum BOD; local MaterialInterface NewMaterial; TeamNum = WalkerVehicle.GetTeamNum(); // we use the walker in DM maps where the team will be 255 if( WalkerVehicle.PowerOrbBurnoutTeamMaterials.length < TeamNum ) { TeamNum = 0; } // set our specific turret BurnOut Material if( ( WalkerVehicle.PowerOrbBurnoutTeamMaterials.length > 0 ) && ( WalkerVehicle.PowerOrbBurnoutTeamMaterials[TeamNum] != None ) ) { NewMaterial = WalkerVehicle.PowerOrbBurnoutTeamMaterials[TeamNum]; WalkerVehicle.Mesh.SetMaterial( 1, NewMaterial ); BOD.MITV = WalkerVehicle.Mesh.CreateAndSetMaterialInstanceTimeVarying(1); WalkerVehicle.BurnOutMaterialInstances[WalkerVehicle.BurnOutMaterialInstances.length] = BOD; } } defaultproperties { Begin Object Class=SkeletalMeshComponent Name=LegMeshComponent ObjName=LegMeshComponent Archetype=SkeletalMeshComponent'Engine.Default__SkeletalMeshComponent' PhysicsWeight=1.000000 bIgnoreControllersWhenNotRendered=True bHasPhysicsAssetInstance=True LightEnvironment=DynamicLightEnvironmentComponent'UTGame.Default__UTWalkerBody:LegLightEnvironmentComp' bUseAsOccluder=False CollideActors=True BlockZeroExtent=True BlockNonZeroExtent=True RBChannel=RBCC_Nothing RBCollideWithChannels=(Default=True,GameplayPhysics=True,EffectPhysics=True) Name="LegMeshComponent" ObjectArchetype=SkeletalMeshComponent'Engine.Default__SkeletalMeshComponent' End Object SkeletalMeshComponent=LegMeshComponent ShoulderSkelControlName(0)="Shoulder1" ShoulderSkelControlName(1)="Shoulder2" ShoulderSkelControlName(2)="Shoulder3" Begin Object Class=UTWalkerStepHandle Name=RB_FootHandle0 ObjName=RB_FootHandle0 Archetype=UTWalkerStepHandle'UTGame.Default__UTWalkerStepHandle' LinearDamping=50.000000 LinearStiffness=10000.000000 Name="RB_FootHandle0" ObjectArchetype=UTWalkerStepHandle'UTGame.Default__UTWalkerStepHandle' End Object FootConstraints(0)=RB_FootHandle0 Begin Object Class=UTWalkerStepHandle Name=RB_FootHandle1 ObjName=RB_FootHandle1 Archetype=UTWalkerStepHandle'UTGame.Default__UTWalkerStepHandle' LinearDamping=50.000000 LinearStiffness=10000.000000 Name="RB_FootHandle1" ObjectArchetype=UTWalkerStepHandle'UTGame.Default__UTWalkerStepHandle' End Object FootConstraints(1)=RB_FootHandle1 Begin Object Class=UTWalkerStepHandle Name=RB_FootHandle2 ObjName=RB_FootHandle2 Archetype=UTWalkerStepHandle'UTGame.Default__UTWalkerStepHandle' LinearDamping=50.000000 LinearStiffness=10000.000000 Name="RB_FootHandle2" ObjectArchetype=UTWalkerStepHandle'UTGame.Default__UTWalkerStepHandle' End Object FootConstraints(2)=RB_FootHandle2 StepStageTimes(0)=0.700000 StepStageTimes(1)=0.135000 StepStageTimes(2)=1.000000 MinStepDist=20.000000 MaxLegReach=450.000000 LandedFootDistSq=400.000000 FootEmbedDistance=8.000000 FootBoneName(0)="Leg1_End" FootBoneName(1)="Leg2_End" FootBoneName(2)="Leg3_End" ShoulderBoneName(0)="Leg1_Shoulder" ShoulderBoneName(1)="Leg2_Shoulder" ShoulderBoneName(2)="Leg3_Shoulder" BodyBoneName="Root" BaseLegDirLocal(0)=(X=-1.000000,Y=0.000000,Z=0.000000) BaseLegDirLocal(1)=(X=0.500000,Y=-0.866025,Z=0.000000) BaseLegDirLocal(2)=(X=0.500000,Y=0.866025,Z=0.000000) FootPosVelAdjScale(0)=1.200000 FootPosVelAdjScale(1)=0.600000 FootPosVelAdjScale(2)=0.600000 FootStepStartLift=512.000000 FootStepEndLift=128.000000 Begin Object Class=DynamicLightEnvironmentComponent Name=LegLightEnvironmentComp ObjName=LegLightEnvironmentComp Archetype=DynamicLightEnvironmentComponent'Engine.Default__DynamicLightEnvironmentComponent' AmbientGlow=(R=0.200000,G=0.200000,B=0.200000,A=1.000000) Name="LegLightEnvironmentComp" ObjectArchetype=DynamicLightEnvironmentComponent'Engine.Default__DynamicLightEnvironmentComponent' End Object LegLightEnvironment=LegLightEnvironmentComp MaxFootStepEffectDist=5000.000000 Components(0)=LegLightEnvironmentComp Components(1)=LegMeshComponent Components(2)=RB_FootHandle0 Components(3)=RB_FootHandle1 Components(4)=RB_FootHandle2 Physics=PHYS_RigidBody TickGroup=TG_PostAsyncWork bIgnoreEncroachers=True bCollideActors=True bProjTarget=True bNoEncroachCheck=True bEdShouldSnap=True CollisionComponent=LegMeshComponent CollisionType=COLLIDE_CustomDefault Name="Default__UTWalkerBody" ObjectArchetype=Actor'Engine.Default__Actor' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |