Core.Object | +--Engine.Actor | +--Engine.Projectile | +--Engine.Fragment
MESH
Fragments[11]
bool
bFirstHit
int
numFragmentTypes
simulated
CalcVelocity(vector Momentum, float ExplosionSize)
HitWall(vector HitNormal, Actor HitWall)
void
PostBeginPlay()
TakeDamage(int Dam, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType)
ZoneChange(ZoneInfo NewZone)
00001 //============================================================================= 00002 // Fragment. 00003 //============================================================================= 00004 class Fragment extends Projectile; 00005 00006 var() MESH Fragments[11]; 00007 var int numFragmentTypes; 00008 var bool bFirstHit; 00009 00010 function PostBeginPlay() 00011 { 00012 if ( Region.Zone.bDestructive ) 00013 Destroy(); 00014 else 00015 Super.PostBeginPlay(); 00016 } 00017 00018 simulated function CalcVelocity(vector Momentum, float ExplosionSize) 00019 { 00020 Velocity = VRand()*(ExplosionSize+FRand()*150.0+100.0 + VSize(Momentum)/80); 00021 } 00022 00023 simulated function HitWall (vector HitNormal, actor HitWall) 00024 { 00025 Velocity = 0.5*(( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity); // Reflect off Wall w/damping 00026 speed = VSize(Velocity); 00027 if (bFirstHit && speed<400) 00028 { 00029 bFirstHit=False; 00030 bRotatetoDesired=True; 00031 bFixedRotationDir=False; 00032 DesiredRotation.Pitch=0; 00033 DesiredRotation.Yaw=FRand()*65536; 00034 DesiredRotation.roll=0; 00035 } 00036 RotationRate.Yaw = RotationRate.Yaw*0.75; 00037 RotationRate.Roll = RotationRate.Roll*0.75; 00038 RotationRate.Pitch = RotationRate.Pitch*0.75; 00039 if ( (speed < 60) && (HitNormal.Z > 0.7) ) 00040 { 00041 SetPhysics(PHYS_none); 00042 bBounce = false; 00043 GoToState('Dying'); 00044 } 00045 else If (speed > 50) 00046 { 00047 if (FRand()<0.5) PlaySound(ImpactSound, SLOT_None, 0.5+FRand()*0.5,, 300, 0.85+FRand()*0.3); 00048 else PlaySound(MiscSound, SLOT_None, 0.5+FRand()*0.5,, 300, 0.85+FRand()*0.3); 00049 } 00050 } 00051 00052 auto state Flying 00053 { 00054 simulated function timer() 00055 { 00056 GoToState('Dying'); 00057 } 00058 00059 00060 simulated function Touch(actor Other) 00061 { 00062 if (Pawn(Other)==None) Return; 00063 if (!Pawn(Other).bIsPlayer) Destroy(); 00064 } 00065 00066 00067 simulated singular function ZoneChange( ZoneInfo NewZone ) 00068 { 00069 local float splashsize; 00070 local actor splash; 00071 00072 if ( NewZone.bWaterZone ) 00073 { 00074 Velocity = 0.2 * Velocity; 00075 splashSize = 0.0005 * (250 - 0.5 * Velocity.Z); 00076 if ( Level.NetMode != NM_DedicatedServer ) 00077 { 00078 if ( NewZone.EntrySound != None ) 00079 PlaySound(NewZone.EntrySound, SLOT_Interact, splashSize); 00080 if ( NewZone.EntryActor != None ) 00081 { 00082 splash = Spawn(NewZone.EntryActor); 00083 if ( splash != None ) 00084 splash.DrawScale = 4 * splashSize; 00085 } 00086 } 00087 if (bFirstHit) 00088 { 00089 bFirstHit=False; 00090 bRotatetoDesired=True; 00091 bFixedRotationDir=False; 00092 DesiredRotation.Pitch=0; 00093 DesiredRotation.Yaw=FRand()*65536; 00094 DesiredRotation.roll=0; 00095 } 00096 00097 RotationRate = 0.2 * RotationRate; 00098 GotoState('Dying'); 00099 } 00100 if ( NewZone.bPainZone && (NewZone.DamagePerSec > 0) ) 00101 Destroy(); 00102 } 00103 00104 simulated function BeginState() 00105 { 00106 RandSpin(125000); 00107 if (RotationRate.Pitch>-10000&&RotationRate.Pitch<10000) 00108 RotationRate.Pitch=10000; 00109 if (RotationRate.Roll>-10000&&RotationRate.Roll<10000) 00110 RotationRate.Roll=10000; 00111 Mesh = Fragments[int(FRand()*numFragmentTypes)]; 00112 if ( Level.NetMode == NM_Standalone ) 00113 LifeSpan = 20 + 40 * FRand(); 00114 SetTimer(5.0,True); 00115 } 00116 } 00117 00118 state Dying 00119 { 00120 simulated function HitWall (vector HitNormal, actor HitWall) 00121 { 00122 Velocity = 0.5*(( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity); // Reflect off Wall w/damping 00123 speed = VSize(Velocity); 00124 if (bFirstHit && speed<400) 00125 { 00126 bFirstHit=False; 00127 bRotatetoDesired=True; 00128 bFixedRotationDir=False; 00129 DesiredRotation.Pitch=0; 00130 DesiredRotation.Yaw=FRand()*65536; 00131 DesiredRotation.roll=0; 00132 } 00133 RotationRate.Yaw = RotationRate.Yaw*0.75; 00134 RotationRate.Roll = RotationRate.Roll*0.75; 00135 RotationRate.Pitch = RotationRate.Pitch*0.75; 00136 if ( (Velocity.Z < 50) && (HitNormal.Z > 0.7) ) 00137 { 00138 SetPhysics(PHYS_none); 00139 bBounce = false; 00140 } 00141 else If (speed > 80) 00142 { 00143 if (FRand()<0.5) PlaySound(ImpactSound, SLOT_None, 0.5+FRand()*0.5,, 300, 0.85+FRand()*0.3); 00144 else PlaySound(MiscSound, SLOT_None, 0.5+FRand()*0.5,, 300, 0.85+FRand()*0.3); 00145 } 00146 } 00147 00148 function TakeDamage( int Dam, Pawn instigatedBy, Vector hitlocation, 00149 Vector momentum, name damageType) 00150 { 00151 Destroy(); 00152 } 00153 00154 simulated function timer() 00155 { 00156 if (!PlayerCanSeeMe()) 00157 Destroy(); 00158 } 00159 00160 simulated function BeginState() 00161 { 00162 SetTimer(1.5,True); 00163 SetCollision(true, false, false); 00164 } 00165 } 00166 00167 defaultproperties 00168 { 00169 bFirstHit=True 00170 bNetTemporary=False 00171 bNetOptional=True 00172 Physics=PHYS_Falling 00173 RemoteRole=ROLE_SimulatedProxy 00174 LifeSpan=20.000000 00175 CollisionRadius=18.000000 00176 CollisionHeight=4.000000 00177 bCollideActors=False 00178 bBounce=True 00179 bFixedRotationDir=True 00180 NetPriority=1.400000 00181 }