Core.Object | +--Engine.Actor | +--Engine.Decoration | +--RuneI.DecorationRune | +--RuneI.Rocks
vector
PrevLocation
void
MakeHitSound(vector hitNormal, float speed)
EMatterType
MatterForJoint(int joint)
//============================================================ // // MatterForJoint // // Returns what kind of material joint is associated with //============================================================
Trigger(Actor other, Pawn eventInstigator)
// FUNCTIONS ------------------------------------------------------------------
Timer()
HitWall(vector hitNormal, Actor hitWall)
Landed(vector HitNormal, Actor HitActor)
EndState()
BeginState()
00001 //============================================================================= 00002 // Rocks. 00003 //============================================================================= 00004 class Rocks expands DecorationRune; 00005 00006 // 00007 // To do: 00008 // 00009 // - Spawn dust and debris when landed() and hitwall() 00010 // - Break into smaller rocks 00011 // - Apply damage when colliding with pawns 00012 // 00013 00014 var vector PrevLocation; 00015 var(Sounds) sound ImpactSound; 00016 00017 00018 // FUNCTIONS ------------------------------------------------------------------ 00019 00020 function Trigger(actor other, pawn eventInstigator) 00021 { 00022 GotoState('FallingRock'); 00023 } 00024 00025 //============================================================ 00026 // 00027 // MatterForJoint 00028 // 00029 // Returns what kind of material joint is associated with 00030 //============================================================ 00031 function EMatterType MatterForJoint(int joint) 00032 { 00033 return MATTER_STONE; 00034 } 00035 00036 function MakeHitSound(vector hitNormal, float speed) 00037 { 00038 local float f, m, v; 00039 local Sound snd; 00040 00041 m = FClamp(Mass, 0, 200); 00042 if(hitNormal.Z < 0) 00043 hitNormal.Z = 0; 00044 f = FRand()*0.15 + hitNormal.Z*0.3 + m*0.00275; 00045 /* if(f < 0.166) 00046 snd = Sound'EnvironmentalSnd.Rocks.Hit1'; 00047 else if(f < 0.333) 00048 snd = Sound'EnvironmentalSnd.Rocks.Hit2'; 00049 else if(f < 0.5) 00050 snd = Sound'EnvironmentalSnd.Rocks.Hit3'; 00051 else if(f < 0.666) 00052 snd = Sound'EnvironmentalSnd.Rocks.Hit4'; 00053 else if(f < 0.833) 00054 snd = Sound'EnvironmentalSnd.Rocks.Hit5'; 00055 else 00056 snd = Sound'EnvironmentalSnd.Rocks.Hit6';*/ 00057 speed = FClamp(speed, 0, 400); 00058 v = f*0.2 + m*0.0015 + speed*0.00125; 00059 PlaySound(ImpactSound,, 0.2+v*0.8,,, 0.9+FRand()*0.2); 00060 } 00061 00062 // STATES --------------------------------------------------------------------- 00063 00064 state FallingRock 00065 { 00066 function BeginState() 00067 { 00068 SetPhysics(PHYS_Falling); 00069 //SetCollision(true, false, false); 00070 //bCollideWorld = true; 00071 bBounce = true; 00072 bFixedRotationDir = true; 00073 DesiredRotation.Yaw = Rotation.Yaw + Rand(2000) - 1000; 00074 RotationRate.Yaw = 50000; 00075 PrevLocation = Vect(0x7fffffff, 0x7fffffff, 0x7fffffff); 00076 } 00077 00078 function EndState() 00079 { 00080 bBounce = false; 00081 //SetCollision(false, false, false); 00082 //bCollideWorld = false; 00083 bBounce = false; 00084 bFixedRotationDir = false; 00085 } 00086 00087 function Landed(vector HitNormal, actor HitActor) 00088 { 00089 HitWall(HitNormal, HitActor); 00090 } 00091 00092 function HitWall(vector hitNormal, actor hitWall) 00093 { 00094 local float speed; 00095 00096 speed = VSize(Velocity); 00097 MakeHitSound(hitNormal, speed); 00098 00099 // Apply a velocity to any pawns that the rock hits 00100 if(hitWall.bIsPawn) 00101 { 00102 Pawn(hitWall).AddVelocity(Velocity * 0.5); 00103 } 00104 00105 if(speed < 10 || (hitNormal.Z > 0.8 && speed < 60) 00106 || PrevLocation == Location) 00107 { 00108 //cjr SetPhysics(PHYS_None); 00109 SetPhysics(PHYS_Falling); 00110 bBounce = false; 00111 bFixedRotationDir = false; 00112 SetTimer(2.0, false); 00113 } 00114 else 00115 { 00116 PrevLocation = Location; 00117 SetPhysics(PHYS_Falling); 00118 RotationRate.Yaw = VSize(Velocity)*100; 00119 00120 if(HitNormal.Z > 0.8) 00121 Velocity = 0.30 * (Velocity - 2 * HitNormal * (Velocity Dot HitNormal)); 00122 else 00123 Velocity = 0.55 * (Velocity - 2 * HitNormal * (Velocity Dot HitNormal)); 00124 00125 DesiredRotation = rotator(HitNormal); 00126 } 00127 } 00128 00129 function Timer() 00130 { 00131 GotoState(''); 00132 } 00133 00134 begin: 00135 } 00136 00137 defaultproperties 00138 { 00139 bDestroyable=True 00140 bStatic=False 00141 DrawType=DT_SkeletalMesh 00142 bCollideActors=True 00143 bCollideWorld=True 00144 bBlockActors=True 00145 bBlockPlayers=True 00146 }