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 |
//============================================================================= // BigRock. //============================================================================= class BigRock extends Projectile; #exec MESH IMPORT MESH=TBoulder ANIVFILE=..\UnrealShare\MODELS\rock_a.3D DATAFILE=..\UnrealShare\MODELS\rock_d.3D X=0 Y=0 Z=0 #exec MESH ORIGIN MESH=TBoulder X=0 Y=0 Z=0 YAW=64 #exec MESH SEQUENCE MESH=TBoulder SEQ=All STARTFRAME=0 NUMFRAMES=4 #exec MESH SEQUENCE MESH=TBoulder SEQ=Pos1 STARTFRAME=0 NUMFRAMES=1 #exec MESH SEQUENCE MESH=TBoulder SEQ=Pos2 STARTFRAME=1 NUMFRAMES=1 #exec MESH SEQUENCE MESH=TBoulder SEQ=Pos3 STARTFRAME=2 NUMFRAMES=1 #exec MESH SEQUENCE MESH=TBoulder SEQ=Pos4 STARTFRAME=3 NUMFRAMES=1 #exec TEXTURE IMPORT NAME=JBoulder1 FILE=..\UnrealShare\MODELS\rock.PCX GROUP=Skins #exec MESHMAP SCALE MESHMAP=TBoulder X=0.01 Y=0.01 Z=0.02 #exec MESHMAP SETTEXTURE MESHMAP=TBoulder NUM=1 TEXTURE=JBoulder1 #exec AUDIO IMPORT FILE="Sounds\Titan\Rockhit1.wav" NAME="Rockhit" GROUP="Titan" function PostBeginPlay() { local float decision; Super.PostBeginPlay(); Velocity = Vector(Rotation) * (0.8 + (0.3 * FRand())) * speed; DesiredRotation.Pitch = Rotation.Pitch + Rand(2000) - 1000; DesiredRotation.Roll = Rotation.Roll + Rand(2000) - 1000; DesiredRotation.Yaw = Rotation.Yaw + Rand(2000) - 1000; decision = FRand(); if (decision<0.25) PlayAnim('Pos2', 1.0, 0.0); else if (decision<0.5) PlayAnim('Pos3', 1.0, 0.0); else if (decision <0.75) PlayAnim('Pos4', 1.0, 0.0); if (FRand() < 0.5) RotationRate.Pitch = Rand(180000); if ( (RotationRate.Pitch == 0) || (FRand() < 0.8) ) RotationRate.Roll = Max(0, 50000 + Rand(200000) - RotationRate.Pitch); } function TakeDamage( int NDamage, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType) { // If a rock is shot, it will fragment into a number of smaller // pieces. The player can fragment a giant boulder which would // otherwise crush him/her, and escape with minor or no wounds // when a multitude of smaller rocks hit. //log ("Rock gets hit by something..."); Velocity += Momentum/(DrawScale * 10); if (Physics == PHYS_None ) { SetPhysics(PHYS_Falling); Velocity.Z += 0.4 * VSize(momentum); } SpawnChunks(4); } function SpawnChunks(int num) { local int NumChunks,i; local BigRock TempRock; local float scale; if ( DrawScale < 1 + FRand() ) return; NumChunks = 1+Rand(num); scale = sqrt(0.52/NumChunks); if ( scale * DrawScale < 1 ) { NumChunks *= scale * DrawScale; scale = 1/DrawScale; } speed = VSize(Velocity); for (i=0; i<NumChunks; i++) { TempRock = Spawn(class'BigRock'); if (TempRock != None ) TempRock.InitFrag(self, scale); } InitFrag(self, 0.5); } function InitFrag(BigRock myParent, float scale) { local rotator newRot; // Pick a random size for the chunks RotationRate = RotRand(); scale *= (0.5 + FRand()); DrawScale = scale * myParent.DrawScale; if ( DrawScale <= 2 ) SetCollisionSize(0,0); else SetCollisionSize(CollisionRadius * DrawScale/Default.DrawScale, CollisionHeight * DrawScale/Default.DrawScale); Velocity = Normal(VRand() + myParent.Velocity/myParent.speed) * (myParent.speed * (0.4 + 0.3 * (FRand() + FRand()))); } auto state Flying { function ProcessTouch (Actor Other, Vector HitLocation) { local int hitdamage; if ( Other == instigator ) return; PlaySound(ImpactSound, SLOT_Interact, DrawScale/10); if ( !Other.IsA('BigRock') && !Other.IsA('Titan') ) { Hitdamage = Damage * 0.00002 * (DrawScale**3) * speed; if ( (HitDamage > 6) && (speed > 150) ) Other.TakeDamage(hitdamage, instigator,HitLocation, (35000.0 * Normal(Velocity)), 'crushed' ); } } simulated function Landed(vector HitNormal) { HitWall(HitNormal, None); } function MakeSound() { local float soundRad; if ( Drawscale > 2.0 ) soundRad = 500 * DrawScale; else soundRad = 100; PlaySound(ImpactSound, SLOT_Misc, DrawScale/8,,soundRad); } simulated function HitWall (vector HitNormal, actor Wall) { local vector RealHitNormal; if ( (Role == ROLE_Authority) && (Mover(Wall) != None) && Mover(Wall).bDamageTriggered ) Wall.TakeDamage( Damage, instigator, Location, MomentumTransfer * Normal(Velocity), ''); speed = VSize(velocity); MakeSound(); if ( (HitNormal.Z > 0.8) && (speed < 60 - DrawScale) ) { SetPhysics(PHYS_None); GotoState('Sitting'); } else { SetPhysics(PHYS_Falling); RealHitNormal = HitNormal; if ( FRand() < 0.5 ) RotationRate.Pitch = Max(RotationRate.Pitch, 100000); else RotationRate.Roll = Max(RotationRate.Roll, 100000); HitNormal = Normal(HitNormal + 0.5 * VRand()); if ( (RealHitNormal Dot HitNormal) < 0 ) HitNormal.Z *= -0.7; Velocity = 0.7 * (Velocity - 2 * HitNormal * (Velocity Dot HitNormal)); DesiredRotation = rotator(HitNormal); if ( (speed > 150) && (FRand() * 30 < DrawScale) ) SpawnChunks(4); } } Begin: Sleep(5.0); SetPhysics(PHYS_Falling); } State Sitting { Begin: SetPhysics(PHYS_None); Sleep(DrawScale * 0.5); Destroy(); } defaultproperties { speed=900.000000 MaxSpeed=1000.000000 Damage=40.000000 ImpactSound=Sound'UnrealI.Titan.Rockhit' bNetTemporary=False Physics=PHYS_Falling RemoteRole=ROLE_SimulatedProxy LifeSpan=20.000000 AnimSequence=Pos1 Mesh=LodMesh'UnrealI.TBoulder' DrawScale=7.500000 CollisionRadius=30.000000 CollisionHeight=30.000000 bBounce=True bFixedRotationDir=True } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |