RuneI
Class Tarp

source: c:\runehov\RuneI\Classes\Tarp.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Decoration
         |
         +--RuneI.DecorationRune
            |
            +--RuneI.Tarp
Direct Known Subclasses:None

class Tarp
extends RuneI.DecorationRune

//============================================================================= // Tarp. //=============================================================================
Variables
 float MaxAppliedVelocity
 float TossVelocity


Function Summary
 void AddVelocity(vector NewVelocity)
 
simulated
Debug(Canvas canvas, int mode)
 bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
 
simulated
JointTouchedBy(Actor Other, int joint)
 
simulated
PostTouch(Actor Other)



Source Code


00001	//=============================================================================
00002	// Tarp.
00003	//=============================================================================
00004	class Tarp extends DecorationRune;
00005	
00006	
00007	var() float TossVelocity;
00008	var(Sounds) Sound JumpTarp;
00009	var() float MaxAppliedVelocity;
00010	
00011	
00012	simulated event GetSpringJointParms(int joint, out float DampFactor, out float SpringConstant, out vector SpringThreshold)
00013	{
00014		DampFactor = 5;
00015		SpringConstant = 300;
00016		SpringThreshold = vect(20,20,100);
00017	}
00018	
00019	
00020	function bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
00021	{
00022		if ((JointFlags[joint]&JOINT_FLAG_COLLISION)!=0)
00023			ApplyJointForce(joint, Momentum);
00024		return true;
00025	}
00026	
00027	function AddVelocity(vector NewVelocity)
00028	{	// Momentum has come in from another actor
00029	}
00030	
00031	simulated function JointTouchedBy(actor Other, int joint)
00032	{
00033		local vector vel;
00034		local vector X,Y,Z;
00035		local float mag;
00036	
00037		if (Other.Velocity.Z < 0)
00038		{
00039			// Apply only velocity in Z direction of joint's local coordinates
00040			GetAxes(Rotation, X,Y,Z);
00041			mag = VSize(Other.Velocity);
00042			mag = Clamp(mag, 0, MaxAppliedVelocity);
00043			vel = -Z * mag;
00044			ApplyJointForce(joint, vel);
00045	
00046			// Slow Other down so he doesn't simulate through ground
00047			Other.Velocity = vect(0,0,0);
00048			Other.Acceleration = vect(0,0,0);
00049	
00050			// Other is still in physics, so add to pendingtouch list
00051			Other.PendingTouch = self;
00052		}
00053	}
00054	
00055	simulated function PostTouch(actor Other)
00056	{
00057		local vector X,Y,Z;
00058	
00059		GetAxes(Rotation, X,Y,Z);
00060	
00061		if (Other.IsA('Inventory') || Other.IsA('Decoration') ||
00062			(Other.IsA('Pawn') && Pawn(Other).Health <= 0))
00063		{	// Make these objects eventually work their way off straight up tarps
00064			Z -= VRand()*0.1;
00065		}
00066	
00067		Other.Acceleration = vect(0,0,0);
00068		Other.SetPhysics(PHYS_Falling);
00069		Other.Velocity = Z*TossVelocity;
00070		PlaySound(JumpTarp, SLOT_Misc,,,, FRand()*0.5 + 0.8);
00071	}
00072	
00073	simulated function Debug(Canvas canvas, int mode)
00074	{
00075		Super.Debug(canvas, mode);
00076		
00077		Canvas.DrawText("Tarp:");
00078		Canvas.CurY -= 8;
00079	}
00080	
00081	defaultproperties
00082	{
00083	     TossVelocity=800.000000
00084	     JumpTarp=Sound'OtherSnd.Instruments.drumhuge05'
00085	     MaxAppliedVelocity=800.000000
00086	     bStatic=False
00087	     DrawType=DT_SkeletalMesh
00088	     CollisionRadius=64.000000
00089	     CollisionHeight=10.000000
00090	     bCollideActors=True
00091	     bBlockActors=True
00092	     bBlockPlayers=True
00093	     bJointsBlock=True
00094	     bJointsTouch=True
00095	     Skeletal=SkelModel'objects.Tarp'
00096	}

End Source Code