Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. //=============================================================================
  2. // DWHealthPack
  3. // A nonrespawnable Health Pickup that decreases in size as its internal
  4. // Health capacity lowers. It also prevents the griefers from steeling all
  5. // health since they can't take more than what their character can handle.
  6. // Author: DW>Ant
  7. // Date: July 12, 2010
  8. //=============================================================================
  9.  
  10. class DWHealthPack extends TournamentHealth
  11. placeable;
  12.  
  13. //Note: HealAmount variable is useless for this actor
  14.  
  15. var() float TotalHealthAmount; //Health amount (only used for initializing)
  16. var() bool bResizePack; //Want the pack to shrink as more health is drained from it?
  17. var() bool bCantTakeAllAtOnce; //if true, the player will have to walk over the pickup multiple times to get it all
  18. var() float HealthPerTouch; //How much Health player will get per touch
  19.  
  20. var float HealthRemaining; //Used for the PercentUse property
  21. var float PercentUsed; //Health pickedup/HealthAmount %
  22. var float InitialDrawScale; //Keep track the original scale
  23. var float CollisionDrawScaleRatio; //What's the ratio of collision / drawscale
  24. var float CollisionDrawScaleRatioHeight; //Same thing, but for the height
  25.  
  26. event PostBeginPlay()
  27. {
  28. if (TotalHealthAmount <= 0)
  29. TotalHealthAmount = 1; //Just in case
  30.  
  31. HealthRemaining = TotalHealthAmount;
  32. InitialDrawScale = DrawScale;
  33. CollisionDrawScaleRatio = default.DrawScale/default.CollisionRadius;
  34. CollisionDrawScaleRatioHeight = default.DrawScale/default.CollisionHeight;
  35. SetCollisionSize(DrawScale/CollisionDrawScaleRatio, DrawScale/CollisionDrawScaleRatioHeight );
  36. }
  37.  
  38. auto state Pickup
  39. {
  40. function Touch( actor Other )
  41. {
  42. local Pawn P;
  43. local float HealthPickUp, MaxPotentialHealth;
  44.  
  45. if ( ValidTouch(Other))
  46. {
  47. P = Pawn(Other);
  48.  
  49. if (P.Health >= P.SuperHealthMax)
  50. return; //Pawn already full, don't pickup
  51. else if (P.Health >= P.HealthMax && !bSuperHeal)
  52. return; //Pawn already full, don't pickup
  53.  
  54. if (bCantTakeAllAtOnce)
  55. {
  56. if (HealthRemaining <= MaxPotentialHealth)
  57. MaxPotentialHealth = HealthRemaining;
  58. else
  59. MaxPotentialHealth = HealthPerTouch;
  60.  
  61. if (MaxPotentialHealth <= (P.HealthMax-P.Health) )
  62. HealthPickUp = MaxPotentialHealth;
  63. else if (bSuperHeal && ( MaxPotentialHealth <= (P.SuperHealthMax - P.Health) ) )
  64. HealthPickUp = MaxPotentialHealth;
  65. else if (bSuperHeal)
  66. HealthPickup = P.SuperHealthMax - P.Health;
  67. else
  68. HealthPickup = P.HealthMax - P.Health;
  69. }
  70. else
  71. {
  72. if (bSuperHeal)
  73. {
  74. if (HealthRemaining <= (P.SuperHealthMax - P.Health) )
  75. HealthPickup = HealthRemaining; //Take what's left
  76. else //Health > Player Max Super Health
  77. HealthPickup = P.SuperHealthMax - P.Health;
  78. }
  79. else
  80. {
  81. if (HealthRemaining <= (P.HealthMax - P.Health) )
  82. HealthPickUp = HealthRemaining; //Take what's left
  83. else //Health > Player Max Health
  84. HealthPickUp = P.HealthMax - P.Health;
  85. }
  86. }
  87.  
  88. HealthRemaining -= HealthPickup;
  89.  
  90. //Resize the pack
  91. if (bResizePack && Role == ROLE_Authority)
  92. ResizePill();
  93.  
  94. if (bSuperHeal)
  95. P.GiveHealth(HealthPickup, P.SuperHealthMax);
  96. else
  97. P.GiveHealth(HealthPickup, P.HealthMax);
  98. AnnouncePickup(P);
  99.  
  100. if (HealthRemaining <= 0)
  101. Destroy(); //Remove the Health if it's out
  102. }
  103. }
  104.  
  105. function ResizePill()
  106. {
  107. PercentUsed = InitialDrawScale * (HealthRemaining/TotalHealthAmount);
  108. SetDrawScale( PercentUsed ); //Resize the pack
  109. if (CollisionRadius <= 10) //Prevent Collision from being impossibly small
  110. SetCollisionSize(DrawScale/CollisionDrawScaleRatio, DrawScale/CollisionDrawScaleRatioHeight ); //Redo the collision
  111. }
  112. }
  113.  
  114. defaultproperties
  115. {
  116. HealthPerTouch=25
  117. bResizePack=True
  118. bSuperHeal=True
  119. CollisionRadius=24
  120. CollisionHeight=23
  121. DrawScale=0.400000
  122. TotalHealthAmount=200
  123. RemoteRole=ROLE_SimulatedProxy
  124.  
  125. PickupSound=sound'PickupSounds.HealthPack'
  126. PickupForce="HealthPack"
  127. DrawType=DT_StaticMesh
  128. StaticMesh=StaticMesh'E_Pickups.MidHealth'
  129. Style=STY_AlphaZ
  130. ScaleGlow=0.6
  131. TransientSoundVolume=0.35
  132. CullDistance=+6500.0
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement