actiondisarmexplosivewithremotedetonatorunpaired.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. class ActionDisarmExplosiveWithRemoteDetonatorUnpairedCB : ActionDisarmExplosiveCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.DISARM_EXPLOSIVE_REMOTE_UNPAIRED);
  6. }
  7. }
  8. class ActionDisarmExplosiveWithRemoteDetonatorUnpaired : ActionDisarmExplosiveWithRemoteDetonator
  9. {
  10. void ActionDisarmExplosiveWithRemoteDetonatorUnpaired()
  11. {
  12. m_CallbackClass = ActionDisarmExplosiveWithRemoteDetonatorUnpairedCB;
  13. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
  14. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
  15. m_FullBody = true;
  16. m_Text = "#disarm";
  17. }
  18. override void CreateConditionComponents()
  19. {
  20. m_ConditionItem = new CCINonRuined();
  21. m_ConditionTarget = new CCTCursor();
  22. }
  23. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  24. {
  25. if (!target)
  26. {
  27. return false;
  28. }
  29. //! explosives only
  30. ExplosivesBase explosive = ExplosivesBase.Cast(target.GetObject());
  31. if (!explosive)
  32. {
  33. return false;
  34. }
  35. if (explosive.IsRuined() || !explosive.GetArmed() || !explosive.CanBeDisarmed())
  36. {
  37. return false;
  38. }
  39. if (explosive.GetAttachmentByType(KitchenTimer) || explosive.GetAttachmentByType(AlarmClock_ColorBase))
  40. {
  41. return false;
  42. }
  43. RemoteDetonatorReceiver attachedReceiver = RemoteDetonatorReceiver.Cast(explosive.GetAttachmentByType(RemoteDetonatorReceiver));
  44. if (!explosive.IsInherited(ClaymoreMine) && attachedReceiver && attachedReceiver.IsRuined())
  45. {
  46. return false;
  47. }
  48. //! RD trigger
  49. RemoteDetonatorTrigger rdt = RemoteDetonatorTrigger.Cast(item);
  50. if (rdt && target.GetObject() != rdt.GetControlledDevice())
  51. {
  52. return true;
  53. }
  54. //! RD kit
  55. RemoteDetonator rd = RemoteDetonator.Cast(item);
  56. if (rd && rd.IsKit())
  57. {
  58. return true;
  59. }
  60. return false;
  61. }
  62. override void OnFinishProgressServer(ActionData action_data)
  63. {
  64. ExplosivesBase target = ExplosivesBase.Cast(action_data.m_Target.GetObject());
  65. ItemBase detonator = ItemBase.Cast(action_data.m_MainItem);
  66. target.Disarm();
  67. target.SetTakeable(true);
  68. //! claymore has integrated detonator
  69. if (target.IsInherited(ClaymoreMine))
  70. {
  71. detonator.Delete();
  72. return;
  73. }
  74. ReplaceItemWithNewLambdaBase lambda = new ReplaceDetonatorItemLambda(detonator, "RemoteDetonator");
  75. MiscGameplayFunctions.TurnItemIntoItemEx(action_data.m_Player, lambda);
  76. //! refresh IK, item changed
  77. action_data.m_Player.GetItemAccessor().OnItemInHandsChanged();
  78. }
  79. }