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 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 00537 00538 00539 00540 00541 00542 00543 00544 00545 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 00577 00578 00579 00580 00581 00582 00583 00584 00585 00586 00587 00588 00589 00590 00591 00592 00593 00594 00595 00596 00597 00598 00599 00600 00601 00602 00603 00604 00605 00606 00607 00608 00609 00610 00611 00612 00613 00614 00615 00616 00617 00618 00619 00620 00621 00622 00623 00624 00625 00626 00627 00628 00629 00630 00631 00632 00633 00634 00635 00636 00637 00638 00639 00640 00641 00642 00643 00644 00645 00646 00647 00648 00649 00650 00651 00652 00653 00654 00655 00656 00657 00658 00659 00660 00661 00662 00663 00664 00665 00666 00667 00668 00669 00670 00671 00672 00673 00674 00675 00676 00677 00678 00679 00680 00681 00682 00683 00684 00685 00686 00687 00688 00689 00690 00691 00692 00693 00694 00695 00696 00697 00698 00699 00700 00701 00702 00703 00704 00705 00706 00707 00708 00709 00710 00711 00712 00713 00714 00715 00716 00717 00718 00719 00720 00721 00722 00723 00724 00725 00726 00727 00728 00729 00730 00731 00732 00733 00734 00735 00736 00737 00738 00739 00740 00741 00742 00743 00744 00745 00746 00747 |
/** * UTProjectile * * This is our base projectile class. * * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved. */ class UTProjectile extends Projectile abstract native nativereplication; /** Additional Sounds */ var bool bSuppressSounds; var SoundCue AmbientSound; // The sound that is played looped. var SoundCue ExplosionSound; // The sound that is played when it explodes /** If true, never cut out ambient sound for perf reasons */ var bool bImportantAmbientSound; /** Effects */ /** This is the effect that is played while in flight */ var ParticleSystemComponent ProjEffects; /** Effects Template */ var ParticleSystem ProjFlightTemplate; var ParticleSystem ProjExplosionTemplate; /** If true, this explosion effect expects to be orientated differently and have extra data passed in via parameters */ var bool bAdvanceExplosionEffect; /** decal for explosion */ var MaterialInterface ExplosionDecal; var float DecalWidth, DecalHeight; /** How long the decal should last before fading out **/ var float DurationOfDecal; /** MaterialInstance param name for dissolving the decal **/ var name DecalDissolveParamName; /** This value sets the cap how far away the explosion effect of this projectile can be seen */ var float MaxEffectDistance; /** used to prevent effects when projectiles are destroyed (see LimitationVolume) */ var bool bSuppressExplosionFX; /** if True, this projectile will remain alive (but hidden) until the flight effect is done */ var bool bWaitForEffects; /** if true, the shutdown function has been called and 'new' effects shouldn't happen */ var bool bShuttingDown; /** Acceleration magnitude. By default, acceleration is in the same direction as velocity */ var float AccelRate; var float TossZ; /** for console games (wider collision w/ enemy players) */ var bool bWideCheck; var float CheckRadius; /** If true, attach explosion effect to vehicles */ var bool bAttachExplosionToVehicles; /** If true, attach explosion effect to pawns */ var bool bAttachExplosionToPawns; /** Make true if want to spawn ProjectileLight. Set false in TickSpecial() once it's been determined whether Instigator is local player. Done there to make sure instigator has been replicated */ var bool bCheckProjectileLight; /** Class of ProjectileLight */ var class<PointLightComponent> ProjectileLightClass; /** LightComponent for this projectile (spawned only if projectile fired by the local player) */ var PointLightComponent ProjectileLight; /** Class of ExplosionLight */ var class<UTExplosionLight> ExplosionLightClass; /** Max distance to create ExplosionLight */ var float MaxExplosionLightDistance; /** TerminalVelocity for this projectile when falling */ var float TerminalVelocity; /** Water buoyancy. A ratio (1.0 = neutral buoyancy, 0.0 = no buoyancy) */ var float Buoyancy; /** custom gravity multiplier */ var float CustomGravityScaling; /** if this projectile is fired by a vehicle passenger gun, this is the base vehicle * considered the same as Instigator for purposes of bBlockedByInstigator */ var Vehicle InstigatorBaseVehicle; // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) replication { if (bNetInitial) bWideCheck; if (bNetDirty && bReplicateInstigator) InstigatorBaseVehicle; } /** returns terminal velocity (max speed while falling) for this actor. Unless overridden, it returns the TerminalVelocity of the PhysicsVolume in which this actor is located. */ native function float GetTerminalVelocity(); /** CreateProjectileLight() called from TickSpecial() once if Instigator is local player */ simulated event CreateProjectileLight() { if ( WorldInfo.bDropDetail ) return; ProjectileLight = new(self) ProjectileLightClass; AttachComponent(ProjectileLight); } /** * Explode when the projectile comes to rest on the floor. It's called from the native physics processing functions. By default, * when we hit the floor, we just explode. */ simulated event Landed( vector HitNormal, actor FloorActor ) { HitWall(HitNormal, FloorActor, None); } simulated function bool CanSplash() { return false; } event PreBeginPlay() { local UTWeaponPawn WeaponPawn; if (UTDummyPawn(Instigator) != None) { // dummy cinematic projectile, turn off net relevance RemoteRole = ROLE_None; bSuppressSounds = UTDummyPawn(Instigator).FireAction.bSuppressSounds; } WeaponPawn = UTWeaponPawn(Instigator); if (WeaponPawn != None) { InstigatorBaseVehicle = WeaponPawn.MyVehicle; } else if (Instigator != None && Instigator.DrivenVehicle != None) { InstigatorBaseVehicle = Instigator.DrivenVehicle; } Super.PreBeginPlay(); } /** * When this actor begins its life, play any ambient sounds attached to it */ simulated function PostBeginPlay() { local AudioComponent AmbientComponent; if (Role == ROLE_Authority) { // If on console, init wide check bWideCheck = bWideCheck || ((CheckRadius > 0) && (Instigator != None) && (UTPlayerController(Instigator.Controller) != None) && UTPlayerController(Instigator.Controller).AimingHelp(false)); } Super.PostBeginPlay(); if ( bDeleteMe || bShuttingDown) return; // Set its Ambient Sound if (AmbientSound != None && WorldInfo.NetMode != NM_DedicatedServer && !bSuppressSounds) { if ( bImportantAmbientSound || (!WorldInfo.bDropDetail && (WorldInfo.GetDetailMode() != DM_Low) && !class'Engine'.static.IsSplitScreen()) ) { AmbientComponent = CreateAudioComponent(AmbientSound, true, true); if ( AmbientComponent != None ) { AmbientComponent.bShouldRemainActiveIfDropped = true; } } } // hack the leviathan shock projectile to use the normal shock ball (leviathan ball is ugly with detail dropping) if (class.name == 'UTProj_LeviathanShockBall') { ProjFlightTemplate = class'UTProj_ShockBall'.default.ProjFlightTemplate; } // Spawn any effects needed for flight SpawnFlightEffects(); } simulated event SetInitialState() { bScriptInitialized = true; if (Role < ROLE_Authority && AccelRate != 0.f) { GotoState('WaitingForVelocity'); } else { GotoState((InitialState != 'None') ? InitialState : 'Auto'); } } /** * Initialize the Projectile */ function Init(vector Direction) { SetRotation(rotator(Direction)); Velocity = Speed * Direction; Velocity.Z += TossZ; Acceleration = AccelRate * Normal(Velocity); } /** * */ simulated function ProcessTouch(Actor Other, Vector HitLocation, Vector HitNormal) { if (DamageRadius > 0.0) { Explode( HitLocation, HitNormal ); } else { Other.TakeDamage(Damage,InstigatorController,HitLocation,MomentumTransfer * Normal(Velocity), MyDamageType,, self); Shutdown(); } } /** * Explode this Projectile */ simulated function Explode(vector HitLocation, vector HitNormal) { if (Damage>0 && DamageRadius>0) { if ( Role == ROLE_Authority ) MakeNoise(1.0); ProjectileHurtRadius(Damage,DamageRadius, MyDamageType, MomentumTransfer, HitLocation, HitNormal ); } SpawnExplosionEffects(HitLocation, HitNormal); ShutDown(); } /** * Hurt locally authoritative actors within the radius. * Projectile version if needed offsets the start of the radius check to prevent hits embedded in walls from failing to cause damage */ simulated function bool ProjectileHurtRadius( float DamageAmount, float InDamageRadius, class<DamageType> DamageType, float Momentum, vector HurtOrigin, vector HitNormal, optional class<DamageType> ImpactedActorDamageType ) { local bool bCausedDamage, bInitializedAltOrigin, bFailedAltOrigin; local Actor Victim; local vector AltOrigin; // Prevent HurtRadius() from being reentrant. if ( bHurtEntry || bShuttingDown ) return false; bHurtEntry = true; bCausedDamage = false; // if ImpactedActor is set, we actually want to give it full damage, and then let him be ignored by super.HurtRadius() if ( (ImpactedActor != None) && (ImpactedActor != self) ) { ImpactedActor.TakeRadiusDamage( InstigatorController, DamageAmount, InDamageRadius, (ImpactedActorDamageType != None) ? ImpactedActorDamageType : DamageType, Momentum, HurtOrigin, true, self ); // need to check again in case TakeRadiusDamage() did something that went through our explosion path a second time if (ImpactedActor != None) { bCausedDamage = ImpactedActor.bProjTarget; } } foreach CollidingActors( class'Actor', Victim, DamageRadius, HurtOrigin ) { if ( !Victim.bWorldGeometry && (Victim != self) && (Victim != ImpactedActor) && (Victim.bProjTarget || (NavigationPoint(Victim) == None)) ) { if ( !FastTrace(HurtOrigin, Victim.Location,, TRUE) ) { // try out from wall, in case trace start was embedded if ( !bInitializedAltOrigin ) { // initialize alternate trace start bInitializedAltOrigin = true; AltOrigin = HurtOrigin + class'UTPawn'.Default.MaxStepHeight * HitNormal; if ( !FastTrace(HurtOrigin, AltOrigin,, TRUE) ) { if ( Velocity == vect(0,0,0) ) { bFailedAltOrigin = true; } else { AltOrigin = HurtOrigin - class'UTPawn'.Default.MaxStepHeight * normal(Velocity); bFailedAltOrigin = !FastTrace(HurtOrigin, AltOrigin,, TRUE); } } } if ( bFailedAltOrigin || !FastTrace(AltOrigin, Victim.Location,, TRUE) ) { continue; } } Victim.TakeRadiusDamage(InstigatorController, DamageAmount, DamageRadius, DamageType, Momentum, HurtOrigin, false, self); bCausedDamage = bCausedDamage || Victim.bProjTarget; } } bHurtEntry = false; return bCausedDamage; } /** * Spawns any effects needed for the flight of this projectile */ simulated function SpawnFlightEffects() { if (WorldInfo.NetMode != NM_DedicatedServer && ProjFlightTemplate != None) { ProjEffects = WorldInfo.MyEmitterPool.SpawnEmitterCustomLifetime(ProjFlightTemplate); ProjEffects.SetAbsolute(false, false, false); ProjEffects.SetLODLevel(WorldInfo.bDropDetail ? 1 : 0); ProjEffects.OnSystemFinished = MyOnParticleSystemFinished; ProjEffects.bUpdateComponentInTick = true; AttachComponent(ProjEffects); } } simulated function bool CheckMaxEffectDistance(PlayerController P, vector SpawnLocation, optional float CullDistance) { local float Dist; if ( P.ViewTarget == None ) return true; if ( (Vector(P.Rotation) Dot (SpawnLocation - P.ViewTarget.Location)) < 0.0 ) { return (VSize(P.ViewTarget.Location - SpawnLocation) < 1000); } Dist = VSize(SpawnLocation - P.ViewTarget.Location); if (CullDistance > 0 && CullDistance < Dist * P.LODDistanceFactor) { return false; } return true; } simulated function bool EffectIsRelevant(vector SpawnLocation, bool bForceDedicated, optional float CullDistance) { local PlayerController PC; // always spawn effect if local player is close, even if not rendered recently if (WorldInfo.NetMode != NM_DedicatedServer && SpawnLocation == Location) { foreach LocalPlayerControllers(class'PlayerController', PC) { if (PC.ViewTarget != None && VSize(PC.ViewTarget.Location - Location) < 256.0) { return true; } } } return Super.EffectIsRelevant(SpawnLocation, bForceDedicated, CullDistance); } /** sets any additional particle parameters on the explosion effect required by subclasses */ simulated function SetExplosionEffectParameters(ParticleSystemComponent ProjExplosion); /** * Spawn Explosion Effects */ simulated function SpawnExplosionEffects(vector HitLocation, vector HitNormal) { local vector LightLoc, LightHitLocation, LightHitNormal; local vector Direction; local ParticleSystemComponent ProjExplosion; local Actor EffectAttachActor; local MaterialInstanceTimeVarying MITV_Decal; local bool bIsPawn, bIsVehicle; if (WorldInfo.NetMode != NM_DedicatedServer) { if (ProjectileLight != None) { DetachComponent(ProjectileLight); ProjectileLight = None; } if (ProjExplosionTemplate != None && EffectIsRelevant(Location, false, MaxEffectDistance)) { //Attach to non-pawns, pawns if we allow it, or vehicles if we allow it bIsPawn = (Pawn(ImpactedActor) != None) ? True : False; bIsVehicle = (UTVehicle(ImpactedActor) != None) ? True : False; EffectAttachActor = (!bIsPawn || (bAttachExplosionToPawns && !bIsVehicle) || (bAttachExplosionToVehicles && bIsVehicle)) ? ImpactedActor : None; if (!bAdvanceExplosionEffect) { ProjExplosion = WorldInfo.MyEmitterPool.SpawnEmitter(ProjExplosionTemplate, HitLocation, rotator(HitNormal), EffectAttachActor); } else { Direction = normal(Velocity - 2.0 * HitNormal * (Velocity dot HitNormal)) * Vect(1,1,0); ProjExplosion = WorldInfo.MyEmitterPool.SpawnEmitter(ProjExplosionTemplate, HitLocation, rotator(Direction), EffectAttachActor); ProjExplosion.SetVectorParameter('Velocity',Direction); ProjExplosion.SetVectorParameter('HitNormal',HitNormal); } SetExplosionEffectParameters(ProjExplosion); if ( !WorldInfo.bDropDetail && ((ExplosionLightClass != None) || (ExplosionDecal != none)) && ShouldSpawnExplosionLight(HitLocation, HitNormal) ) { if ( ExplosionLightClass != None ) { if (Trace(LightHitLocation, LightHitNormal, HitLocation + (0.25 * ExplosionLightClass.default.TimeShift[0].Radius * HitNormal), HitLocation, false) == None) { LightLoc = HitLocation + (0.25 * ExplosionLightClass.default.TimeShift[0].Radius * (vect(1,0,0) >> ProjExplosion.Rotation)); } else { LightLoc = HitLocation + (0.5 * VSize(HitLocation - LightHitLocation) * (vect(1,0,0) >> ProjExplosion.Rotation)); } UTEmitterPool(WorldInfo.MyEmitterPool).SpawnExplosionLight(ExplosionLightClass, LightLoc, EffectAttachActor); } // this code is mostly duplicated in: UTGib, UTProjectile, UTVehicle, UTWeaponAttachment be aware when updating if (ExplosionDecal != None && Pawn(ImpactedActor) == None && (UTOnslaughtNodeObjective(ImpactedActor) == None) ) { if( MaterialInstanceTimeVarying(ExplosionDecal) != none ) { // hack, since they don't show up on terrain anyway if ( Terrain(ImpactedActor) == None ) { MITV_Decal = new(self) class'MaterialInstanceTimeVarying'; MITV_Decal.SetParent( ExplosionDecal ); WorldInfo.MyDecalManager.SpawnDecal(MITV_Decal, HitLocation, rotator(-HitNormal), DecalWidth, DecalHeight, 10.0, FALSE ); //here we need to see if we are an MITV and then set the burn out times to occur MITV_Decal.SetScalarStartTime( DecalDissolveParamName, DurationOfDecal ); } } else { WorldInfo.MyDecalManager.SpawnDecal( ExplosionDecal, HitLocation, rotator(-HitNormal), DecalWidth, DecalHeight, 10.0, true ); } } } } if (ExplosionSound != None && !bSuppressSounds) { PlaySound(ExplosionSound, true); } bSuppressExplosionFX = true; // so we don't get called again } } /** ShouldSpawnExplosionLight() Decide whether or not to create an explosion light for this explosion */ simulated function bool ShouldSpawnExplosionLight(vector HitLocation, vector HitNormal) { local PlayerController P; local float Dist; // decide whether to spawn explosion light ForEach LocalPlayerControllers(class'PlayerController', P) { Dist = VSize(P.ViewTarget.Location - Location); if ( (P.Pawn == Instigator) || (Dist < ExplosionLightClass.Default.Radius) || ((Dist < MaxExplosionLightDistance) && ((vector(P.Rotation) dot (Location - P.ViewTarget.Location)) > 0)) ) { return true; } } return false; } /** * Clean up */ simulated function Shutdown() { local vector HitLocation, HitNormal; bShuttingDown=true; HitNormal = normal(Velocity * -1); Trace(HitLocation,HitNormal,(Location + (HitNormal*-32)), Location + (HitNormal*32),true,vect(0,0,0)); SetPhysics(PHYS_None); if (ProjEffects!=None) { ProjEffects.DeactivateSystem(); } if (WorldInfo.NetMode != NM_DedicatedServer && !bSuppressExplosionFX) { SpawnExplosionEffects(Location, HitNormal); } HideProjectile(); SetCollision(false,false); // If we have to wait for effects, tweak the death conditions if (bWaitForEffects) { if (bNetTemporary) { if ( WorldInfo.NetMode == NM_DedicatedServer ) { // We are on a dedicated server and not replicating anything nor do we have effects so destroy right away Destroy(); } else { // We can't die right away but make sure we don't replicate to anyone RemoteRole = ROLE_None; // make sure we leave enough lifetime for the effect to play LifeSpan = FMax(LifeSpan, 2.0); } } else { bTearOff = true; if (WorldInfo.NetMode == NM_DedicatedServer) { LifeSpan = 0.15; } else { // make sure we leave enough lifetime for the effect to play LifeSpan = FMax(LifeSpan, 2.0); } } } else { Destroy(); } } // If this actor event TornOff() { ShutDown(); Super.TornOff(); } /** * Hide any meshes/etc. */ simulated function HideProjectile() { local MeshComponent ComponentIt; foreach ComponentList(class'MeshComponent',ComponentIt) { ComponentIt.SetHidden(true); } } simulated function Destroyed() { // Final Failsafe check for explosion effect if (WorldInfo.NetMode != NM_DedicatedServer && !bSuppressExplosionFX) { SpawnExplosionEffects(Location, vector(Rotation) * -1); } if (ProjEffects != None) { DetachComponent(ProjEffects); WorldInfo.MyEmitterPool.OnParticleSystemFinished(ProjEffects); ProjEffects = None; } super.Destroyed(); } simulated function MyOnParticleSystemFinished(ParticleSystemComponent PSC) { if (PSC == ProjEffects) { if (bWaitForEffects) { if (bShuttingDown) { // it is not safe to destroy the actor here because other threads are doing stuff, so do it next tick LifeSpan = 0.01; } else { bWaitForEffects = false; } } // clear component and return to pool DetachComponent(ProjEffects); WorldInfo.MyEmitterPool.OnParticleSystemFinished(ProjEffects); ProjEffects = None; } } /** state used only on the client for projectiles with AccelRate > 0 to wait for Velocity to be replicated so we can use it to set Acceleration * the alternative would be to make Velocity repnotify in Actor.uc, but since many Actors (such as Pawns) change their * velocity very frequently, that would have a greater performance hit */ state WaitingForVelocity { simulated function Tick(float DeltaTime) { if (!IsZero(Velocity)) { Acceleration = AccelRate * Normal(Velocity); GotoState((InitialState != 'None') ? InitialState : 'Auto'); } } } simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV ) { out_CamLoc = Location + (CylinderComponent.CollisionHeight * Vect(0,0,1)); return true; } event Actor GetHomingTarget(UTProjectile Seeker, Controller InstigatedBy) { return self; } /** called when this Projectile is the ViewTarget of a local player * @return the Pawn to use for rendering HUD displays */ simulated function Pawn GetPawnOwner(); /** calculate travel time for something to move Dist units with the given movement parameters * @param Dist - distance to travel * @param MoveSpeed - starting speed * @param MaxMoveSpeed - maximum speed (acceleration stops being applied when we reach this) * @param AccelMag - rate of acceleration * @return travel time */ static final function float CalculateTravelTime(float Dist, float MoveSpeed, float MaxMoveSpeed, float AccelMag) { local float ProjTime, AccelTime, AccelDist; if (AccelMag == 0.0) { return (Dist / MoveSpeed); } else { // figure out how long it would take if we accelerated the whole way ProjTime = (-MoveSpeed + Sqrt(Square(MoveSpeed) - (2.0 * AccelMag * -Dist))) / AccelMag; // figure out how long it will actually take to accelerate to max speed AccelTime = (MaxMoveSpeed - MoveSpeed) / AccelMag; if (ProjTime > AccelTime) { // figure out distance traveled while accelerating to max speed AccelDist = (MoveSpeed * AccelTime) + (0.5 * AccelMag * Square(AccelTime)); // add time to accelerate to max speed plus time to travel remaining dist at max speed ProjTime = AccelTime + ((Dist - AccelDist) / MaxMoveSpeed); } return ProjTime; } } static simulated function float StaticGetTimeToLocation(vector TargetLoc, vector StartLoc, Controller RequestedBy) { return CalculateTravelTime(VSize(TargetLoc - StartLoc), default.Speed, default.MaxSpeed, default.AccelRate); } simulated function float GetTimeToLocation(vector TargetLoc) { return CalculateTravelTime(VSize(TargetLoc - Location), Speed, MaxSpeed, AccelRate); } simulated static function float GetRange() { local float AccelTime; if (default.LifeSpan == 0.0) { return 15000.0; } else if (default.AccelRate == 0.0) { return (default.Speed * default.LifeSpan); } else { AccelTime = (default.MaxSpeed - default.Speed) / default.AccelRate; if (AccelTime < default.LifeSpan) { return ((0.5 * default.AccelRate * AccelTime * AccelTime) + (default.Speed * AccelTime) + (default.MaxSpeed * (default.LifeSpan - AccelTime))); } else { return (0.5 * default.AccelRate * default.LifeSpan * default.LifeSpan) + (default.Speed * default.LifeSpan); } } } defaultproperties { bAttachExplosionToVehicles=True bAttachExplosionToPawns=True DurationOfDecal=4.000000 DecalDissolveParamName="DissolveAmount" MaxEffectDistance=10000.000000 MaxExplosionLightDistance=4000.000000 TerminalVelocity=3500.000000 CustomGravityScaling=1.000000 bSwitchToZeroCollision=True bBlockedByInstigator=False bInitRotationFromVelocity=True DamageRadius=0.000000 Begin Object Class=CylinderComponent Name=CollisionCylinder ObjName=CollisionCylinder Archetype=CylinderComponent'Engine.Default__Projectile:CollisionCylinder' ObjectArchetype=CylinderComponent'Engine.Default__Projectile:CollisionCylinder' End Object CylinderComponent=CollisionCylinder Components(0)=CollisionCylinder bNeverReplicateRotation=True bCollideComplex=True CollisionComponent=CollisionCylinder Name="Default__UTProjectile" ObjectArchetype=Projectile'Engine.Default__Projectile' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |