Advertisement
Trebit

Untitled

Apr 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. function PlayDyingAnimation(class<DamageType> DamageType, vector HitLoc)
  2. {
  3. local vector shotDir, hitLocRel, deathAngVel, shotStrength;
  4. local float maxDim;
  5. local string RagSkelName;
  6. local KarmaParamsSkel skelParams;
  7. local bool PlayersRagdoll;
  8. local PlayerController pc;
  9.  
  10. if ( Level.NetMode != NM_DedicatedServer )
  11. {
  12. // Is this the local player's ragdoll?
  13. if(OldController != None)
  14. pc = PlayerController(OldController);
  15. if( pc != none && pc.ViewTarget == self )
  16. PlayersRagdoll = true;
  17.  
  18. // In low physics detail, if we were not just controlling this pawn,
  19. // and it has not been rendered in 3 seconds, just destroy it.
  20. if( !PlayersRagdoll && (Level.TimeSeconds-LastRenderTime)>3 )
  21. {
  22. GoTo'NonRagdoll';
  23. return;
  24. }
  25.  
  26. // Try and obtain a rag-doll setup. Use optional 'override' one out of player record first, then use the species one.
  27. if( RagdollOverride != "")
  28. RagSkelName = RagdollOverride;
  29. else if(Species != None)
  30. RagSkelName = Species.static.GetRagSkelName( GetMeshName() );
  31. else RagSkelName = "Male1"; // Otherwise assume it is Male1 ragdoll were after here.
  32.  
  33. KMakeRagdollAvailable();
  34.  
  35. if( KIsRagdollAvailable() && RagSkelName != "" )
  36. {
  37. skelParams = KarmaParamsSkel(KParams);
  38. skelParams.KSkeleton = RagSkelName;
  39.  
  40. // Stop animation playing.
  41. StopAnimating(true);
  42.  
  43. if( DamageType != None )
  44. {
  45. if ( DamageType.default.bLeaveBodyEffect )
  46. TearOffMomentum = vect(0,0,0);
  47.  
  48. if( DamageType.default.bKUseOwnDeathVel )
  49. {
  50. RagDeathVel = DamageType.default.KDeathVel;
  51. RagDeathUpKick = DamageType.default.KDeathUpKick;
  52. }
  53. }
  54.  
  55. // Set the dude moving in direction he was shot in general
  56. shotDir = Normal(GetTearOffMomemtum());
  57. shotStrength = RagDeathVel * shotDir;
  58.  
  59. // Calculate angular velocity to impart, based on shot location.
  60. hitLocRel = TakeHitLocation - Location;
  61.  
  62. // We scale the hit location out sideways a bit, to get more spin around Z.
  63. hitLocRel.X *= RagSpinScale;
  64. hitLocRel.Y *= RagSpinScale;
  65.  
  66. // If the tear off momentum was very small for some reason, make up some angular velocity for the pawn
  67. if( VSize(GetTearOffMomemtum()) < 0.01 )
  68. {
  69. //Log("TearOffMomentum magnitude of Zero");
  70. deathAngVel = VRand() * 18000.0;
  71. }
  72. else deathAngVel = RagInvInertia * (hitLocRel Cross shotStrength);
  73.  
  74. // Set initial angular and linear velocity for ragdoll.
  75. // Scale horizontal velocity for characters - they run really fast!
  76. if ( DamageType.Default.bRubbery )
  77. skelParams.KStartLinVel = vect(0,0,0);
  78. if ( Damagetype.default.bKUseTearOffMomentum )
  79. skelParams.KStartLinVel = GetTearOffMomemtum() + Velocity;
  80. else
  81. {
  82. skelParams.KStartLinVel.X = 0.6 * Velocity.X;
  83. skelParams.KStartLinVel.Y = 0.6 * Velocity.Y;
  84. skelParams.KStartLinVel.Z = 1.0 * Velocity.Z;
  85. skelParams.KStartLinVel += shotStrength;
  86. }
  87. // If not moving downwards - give extra upward kick
  88. if( !DamageType.default.bLeaveBodyEffect && !DamageType.Default.bRubbery && (Velocity.Z > -10) )
  89. skelParams.KStartLinVel.Z += RagDeathUpKick;
  90.  
  91. if ( DamageType.Default.bRubbery )
  92. {
  93. Velocity = vect(0,0,0);
  94. skelParams.KStartAngVel = vect(0,0,0);
  95. }
  96. else
  97. {
  98. skelParams.KStartAngVel = deathAngVel;
  99.  
  100. // Set up deferred shot-bone impulse
  101. maxDim = Max(CollisionRadius, CollisionHeight);
  102.  
  103. skelParams.KShotStart = TakeHitLocation - (1 * shotDir);
  104. skelParams.KShotEnd = TakeHitLocation + (2*maxDim*shotDir);
  105. skelParams.KShotStrength = RagShootStrength;
  106. }
  107.  
  108. // If this damage type causes convulsions, turn them on here.
  109. if(DamageType != None && DamageType.default.bCauseConvulsions)
  110. {
  111. RagConvulseMaterial=DamageType.default.DamageOverlayMaterial;
  112. skelParams.bKDoConvulsions = true;
  113. }
  114.  
  115. // Turn on Karma collision for ragdoll.
  116. KSetBlockKarma(true);
  117.  
  118. // Set physics mode to ragdoll.
  119. // This doesn't actaully start it straight away, it's deferred to the first tick.
  120. SetPhysics(PHYS_KarmaRagdoll);
  121.  
  122. // If viewing this ragdoll, set the flag to indicate that it is 'important'
  123. if( PlayersRagdoll )
  124. skelParams.bKImportantRagdoll = true;
  125.  
  126. skelParams.bRubbery = DamageType.Default.bRubbery;
  127. bRubbery = DamageType.Default.bRubbery;
  128.  
  129. skelParams.KActorGravScale = RagGravScale;
  130.  
  131. return;
  132. }
  133. // jag
  134. }
  135.  
  136. NonRagdoll:
  137. // non-ragdoll death fallback
  138. LifeSpan = 0.2f;
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement