Guest User

Deus Ex Locational Damage

a guest
Sep 26th, 2025
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. function EHitLocation HandleDamage(int actualDamage, Vector hitLocation, Vector offset, name damageType)
  2. {
  3. local EHitLocation hitPos;
  4. local float headOffsetZ, headOffsetY, armOffset;
  5.  
  6. // calculate our hit extents
  7. headOffsetZ = CollisionHeight * 0.7;
  8. headOffsetY = CollisionRadius * 0.3;
  9. armOffset = CollisionRadius * 0.35;
  10.  
  11. hitPos = HITLOC_None;
  12.  
  13. if (actualDamage > 0)
  14. {
  15. if (offset.z > headOffsetZ) // head
  16. {
  17. // narrow the head region
  18. if ((Abs(offset.x) < headOffsetY) || (Abs(offset.y) < headOffsetY))
  19. {
  20. // don't allow headshots with stunning weapons
  21. if ((damageType == 'Stunned') || (damageType == 'KnockedOut'))
  22. HealthHead -= actualDamage;
  23. else
  24. HealthHead -= actualDamage * 8;
  25. if (offset.x < 0.0)
  26. hitPos = HITLOC_HeadBack;
  27. else
  28. hitPos = HITLOC_HeadFront;
  29. }
  30. else // sides of head treated as torso
  31. {
  32. HealthTorso -= actualDamage * 2;
  33. if (offset.x < 0.0)
  34. hitPos = HITLOC_TorsoBack;
  35. else
  36. hitPos = HITLOC_TorsoFront;
  37. }
  38. }
  39. else if (offset.z < 0.0) // legs
  40. {
  41. if (offset.y > 0.0)
  42. {
  43. HealthLegRight -= actualDamage * 2;
  44. if (offset.x < 0.0)
  45. hitPos = HITLOC_RightLegBack;
  46. else
  47. hitPos = HITLOC_RightLegFront;
  48. }
  49. else
  50. {
  51. HealthLegLeft -= actualDamage * 2;
  52. if (offset.x < 0.0)
  53. hitPos = HITLOC_LeftLegBack;
  54. else
  55. hitPos = HITLOC_LeftLegFront;
  56. }
  57.  
  58. // if this part is already dead, damage the adjacent part
  59. if ((HealthLegRight < 0) && (HealthLegLeft > 0))
  60. {
  61. HealthLegLeft += HealthLegRight;
  62. HealthLegRight = 0;
  63. }
  64. else if ((HealthLegLeft < 0) && (HealthLegRight > 0))
  65. {
  66. HealthLegRight += HealthLegLeft;
  67. HealthLegLeft = 0;
  68. }
  69.  
  70. if (HealthLegLeft < 0)
  71. {
  72. HealthTorso += HealthLegLeft;
  73. HealthLegLeft = 0;
  74. }
  75. if (HealthLegRight < 0)
  76. {
  77. HealthTorso += HealthLegRight;
  78. HealthLegRight = 0;
  79. }
  80. }
  81. else // arms and torso
  82. {
  83. if (offset.y > armOffset)
  84. {
  85. HealthArmRight -= actualDamage * 2;
  86. if (offset.x < 0.0)
  87. hitPos = HITLOC_RightArmBack;
  88. else
  89. hitPos = HITLOC_RightArmFront;
  90. }
  91. else if (offset.y < -armOffset)
  92. {
  93. HealthArmLeft -= actualDamage * 2;
  94. if (offset.x < 0.0)
  95. hitPos = HITLOC_LeftArmBack;
  96. else
  97. hitPos = HITLOC_LeftArmFront;
  98. }
  99. else
  100. {
  101. HealthTorso -= actualDamage * 2;
  102. if (offset.x < 0.0)
  103. hitPos = HITLOC_TorsoBack;
  104. else
  105. hitPos = HITLOC_TorsoFront;
  106. }
  107.  
  108. // if this part is already dead, damage the adjacent part
  109. if (HealthArmLeft < 0)
  110. {
  111. HealthTorso += HealthArmLeft;
  112. HealthArmLeft = 0;
  113. }
  114. if (HealthArmRight < 0)
  115. {
  116. HealthTorso += HealthArmRight;
  117. HealthArmRight = 0;
  118. }
  119. }
  120. }
  121.  
  122. GenerateTotalHealth();
  123.  
  124. return hitPos;
  125.  
  126. }
Advertisement
Add Comment
Please, Sign In to add comment