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 |
/****************************************************************************** Projectile for NetworkProjectileSpawner. This implementation relies only on the replication of the owning spawner actor and grabs its properties clientsidely. Creation date: 2010-06-07 11:31 Last change: $Id$ Copyright © 2010, Wormbo Website: http://www.koehler-homepage.de/Wormbo/ Feel free to reuse this code. Send me a note if you found it helpful or want to report bugs/provide improvements. Please ask for permission first, if you intend to make money off reused code. ******************************************************************************/ class NetworkSpawnerProjectile extends Projectile; var NetworkProjectileSpawner Spawner; var Actor TrailEffect; var int BouncesLeft; var float DampenFactor, DampenFactorParallel; var bool bCanHitInstigator; replication { reliable if (bNetInitial) Spawner, bCanHitInstigator; } event PostBeginPlay() { Spawner = NetworkProjectileSpawner(Owner); Velocity = Spawner.InitialVelocity >> Rotation; Acceleration = Spawner.AccelRate * vector(Rotation); if (Spawner.bApplyGravity) SetPhysics(PHYS_Falling); bIgnoreTerminalVelocity = !Spawner.bApplyTerminalVelocity; // ambient sound (also determines net relevance) AmbientSound = Spawner.FlightAmbientSound; SoundRadius = Spawner.FlightAmbientSoundRadius; } simulated function Destroyed() { if (LifeSpan < 0) Explode(vect(0,0,1), Location); KillTrail(); Super.Destroyed(); } simulated function KillTrail() { if (Emitter(TrailEffect) != None) { Emitter(TrailEffect).Kill(); } else if (xEmitter(TrailEffect) != None && xEmitter(TrailEffect).mRegen) { xEmitter(TrailEffect).mRegen = False; TrailEffect.LifeSpan = FMax(xEmitter(TrailEffect).mLifeRange[0], xEmitter(TrailEffect).mLifeRange[1]); } else if (TrailEffect != None) { TrailEffect.Destroy(); } TrailEffect = None; } simulated function PostNetBeginPlay() { local PlayerController PC; if (Spawner != None) { if (!Spawner.bFaceMovementDirection) Disable('Tick'); MaxSpeed = Spawner.MaxSpeed; RotationRate = Spawner.ProjectileRotationRate; BouncesLeft = Spawner.MaxNumBounces; DampenFactor = Spawner.BounceDampenFactor; DampenFactorParallel = Spawner.BounceDampenFactorParallel; Damage = Spawner.Damage; DamageRadius = Spawner.DamageRadius; MyDamageType = Spawner.DamageType; MomentumTransfer = Spawner.DamageMomentum; LifeSpan = Spawner.ProjectileLifeSpan; } if (Level.NetMode != NM_DedicatedServer) { if (Spawner != None) { SetDrawScale(Spawner.ProjectileScale); SetDrawScale3D(Spawner.ProjectileScale3D); PrePivot = Spawner.ProjectilePrePivot; bUnlit = Spawner.bProjectileUnlit; Style = Spawner.ProjectileRenderStyle; AmbientGlow = Spawner.ProjectileAmbientGlow; if (Spawner.ProjectileStaticMesh != None) { SetDrawType(DT_StaticMesh); SetStaticMesh(Spawner.ProjectileStaticMesh); Skins = Spawner.ProjectileSkins; } else if (Spawner.ProjectileMesh != None) { SetDrawType(DT_Mesh); LinkMesh(Spawner.ProjectileMesh); Skins = Spawner.ProjectileSkins; } else if (Spawner.ProjectileSprite != None) { SetDrawType(DT_Sprite); Texture = Spawner.ProjectileSprite; } if (Spawner.TrailEffectClass != None) { TrailEffect = Spawn(Spawner.TrailEffectClass, Self, '', Location, Rotation); if (TrailEffect != None) { TrailEffect.RemoteRole = ROLE_None; // so clients don't have duplicate trails on listen servers TrailEffect.SetPhysics(PHYS_Trailer); } } ExplosionDecal = Spawner.ExplosionDecal; } if (Spawner.ProjectileLightRadius > 0) { PC = Level.GetLocalPlayerController(); if (PC != None && PC.ViewTarget != None && VSize(PC.ViewTarget.Location - Location) < 4000) { bDynamicLight = true; LightType = LT_Steady; LightEffect = Spawner.ProjectileLightEffect; LightRadius = Spawner.ProjectileLightRadius; LightBrightness = Spawner.ProjectileLightBrightness; LightHue = Spawner.ProjectileLightHue; LightSaturation = Spawner.ProjectileLightSaturation; } } } bReadyToSplash = true; SetTimer(0.1, false); } simulated function Tick(float DeltaTime) { local rotator NewRot; if (Velocity != vect(0,0,0)) { NewRot = rotator(Velocity); NewRot.Roll = Rotation.Roll; SetRotation(NewRot); } } simulated function Timer() { bCanHitInstigator = True; } simulated function ProcessTouch(Actor Other, vector HitLocation) { local vector RefNormal, RefDir; if (Spawner != None && Spawner.bReflectableProjectile) { if (Other == Instigator) return; if (xPawn(Other) != None && xPawn(Other).CheckReflect(HitLocation, RefNormal, Spawner.ReflectionCost)) { if (Role == ROLE_Authority) { RefDir = MirrorVectorByNormal(Velocity, RefNormal); Other.Spawn(Class, Spawner, Tag, HitLocation + Normal(RefDir) * 20, rotator(RefDir)); Other.Velocity = RefDir; // override spawner's initial velocity } Destroy(); return; } } Super.ProcessTouch(Other, HitLocation); } simulated function HitWall(vector HitNormal, Actor Wall) { local vector VNorm; local Actor BounceEffect; if (Pawn(Wall) == None && GameObjective(Wall) == None && BouncesLeft-- != 0) { VNorm = (Velocity dot HitNormal) * HitNormal; Velocity = -VNorm * DampenFactor + (Velocity - VNorm) * DampenFactorParallel; if (Spawner != None) { if (Spawner.BounceSound != None) PlaySound(Spawner.BounceSound,, Spawner.BounceSoundVolume,, Spawner.BounceSoundRadius, Spawner.BounceSoundPitch); if (Spawner.BounceEffectClass != None && EffectIsRelevant(Location, false)) { BounceEffect = Spawn(Spawner.BounceEffectClass,,,, rotator(HitNormal)); if (BounceEffect != none) BounceEffect.RemoteRole = ROLE_None; } if (VSize(Velocity) < Spawner.MinBounceSpeed && HitNormal.Z > 0.7) SetPhysics(PHYS_None); else if (Spawner.bApplyGravityAfterBounce) SetPhysics(PHYS_Falling); } return; } Super.HitWall(HitNormal, Wall); } simulated function Explode(vector HitLocation, vector HitNormal) { local Actor ExplosionEffect; BlowUp(HitLocation); if (Spawner != None) { if (Spawner.ExplosionSound != None) PlaySound(Spawner.ExplosionSound,, Spawner.ExplosionSoundVolume,, Spawner.ExplosionSoundRadius, Spawner.ExplosionSoundPitch); if (Spawner.ExplosionEffectClass != None && EffectIsRelevant(Location, false)) { ExplosionEffect = Spawn(Spawner.ExplosionEffectClass,,,, rotator(HitNormal)); if (ExplosionEffect != none) ExplosionEffect.RemoteRole = ROLE_None; } } if (!bPendingDelete) Destroy(); } //============================================================================= // Default values //============================================================================= defaultproperties { DrawType = DT_None LifeSpan = 30.0 bBounce = True bFixedRotationDir = True } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |