handcuffslocked.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. class RestrainingToolLocked extends ItemBase
  2. {
  3. void ~RestrainingToolLocked()
  4. {
  5. PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
  6. if ( player && player.IsRestrained() )
  7. {
  8. player.SetRestrained(false);
  9. }
  10. }
  11. override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
  12. {
  13. super.EEItemLocationChanged(oldLoc, newLoc);
  14. if ( GetGame().IsServer() )
  15. {
  16. if ( oldLoc.IsValid() && oldLoc.GetParent() )
  17. {
  18. PlayerBase old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
  19. if (old_player && old_player.IsRestrained())
  20. {
  21. old_player.SetRestrained(false);
  22. }
  23. }
  24. }
  25. if ( newLoc.IsValid() )
  26. {
  27. if (newLoc.GetParent())
  28. {
  29. PlayerBase player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
  30. if ( player )
  31. {
  32. if ( newLoc.GetType() == InventoryLocationType.HANDS )
  33. {
  34. if ( !player.IsRestrained() )
  35. {
  36. player.SetRestrained(true);
  37. player.OnItemInHandsChanged();
  38. }
  39. if (player.IsControlledPlayer())
  40. player.OnRestrainStart();
  41. }
  42. }
  43. }
  44. }
  45. if ( GetGame().IsServer() )
  46. {
  47. if ( newLoc.GetType() != InventoryLocationType.HANDS )
  48. {
  49. if (oldLoc.GetParent())
  50. {
  51. PlayerBase old_p = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
  52. if (old_p)
  53. {
  54. MiscGameplayFunctions.TransformRestrainItem(this, null, old_p, old_p);
  55. return;
  56. }
  57. }
  58. Delete();
  59. }
  60. }
  61. }
  62. override void EEKilled(Object killer)
  63. {
  64. super.EEKilled(killer);
  65. InventoryLocation inventoryLocation = new InventoryLocation();
  66. GetInventory().GetCurrentInventoryLocation(inventoryLocation);
  67. if (!inventoryLocation || !inventoryLocation.IsValid())
  68. return;
  69. if (inventoryLocation.GetType() == InventoryLocationType.HANDS)
  70. {
  71. PlayerBase player = PlayerBase.Cast(inventoryLocation.GetParent());
  72. if (player && player.IsRestrained())
  73. {
  74. player.SetRestrained(false);
  75. MiscGameplayFunctions.TransformRestrainItem(this, null, player, player);
  76. }
  77. }
  78. }
  79. override void SetActions()
  80. {
  81. super.SetActions();
  82. AddAction(ActionUnrestrainSelf);
  83. }
  84. }
  85. class HandcuffsLocked extends RestrainingToolLocked
  86. {
  87. }
  88. class RopeLocked extends RestrainingToolLocked
  89. {
  90. }
  91. class DuctTapeLocked extends RestrainingToolLocked
  92. {
  93. }
  94. class MetalWireLocked extends RestrainingToolLocked
  95. {
  96. }
  97. class BarbedWireLocked extends RestrainingToolLocked
  98. {
  99. }