actiondisarmexplosivewithremotedetonator.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. class ActionDisarmExplosiveWithRemoteDetonatorCB : ActionDisarmExplosiveCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.DISARM_EXPLOSIVE_REMOTE_PAIRED);
  6. }
  7. }
  8. class ActionDisarmExplosiveWithRemoteDetonator : ActionDisarmExplosive
  9. {
  10. void ActionDisarmExplosiveWithRemoteDetonator()
  11. {
  12. m_CallbackClass = ActionDisarmExplosiveWithRemoteDetonatorCB;
  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 CCTNonRuined();
  22. }
  23. override bool CanBeSetFromInventory()
  24. {
  25. return true;
  26. }
  27. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  28. {
  29. if (!target)
  30. return false;
  31. ExplosivesBase explosive = ExplosivesBase.Cast(target.GetObject());
  32. if (!explosive)
  33. return false;
  34. if (explosive.IsRuined() || !explosive.GetArmed() || !explosive.CanBeDisarmed())
  35. return false;
  36. if (explosive.GetAttachmentByType(KitchenTimer) || explosive.GetAttachmentByType(AlarmClock_ColorBase))
  37. return false;
  38. RemoteDetonatorTrigger rdt = RemoteDetonatorTrigger.Cast(item);
  39. if (rdt && rdt.IsConnected())
  40. {
  41. if (explosive != rdt.GetControlledDevice())
  42. return false;
  43. ExplosivesBase controlledDevice = ExplosivesBase.Cast(rdt.GetControlledDevice());
  44. if (controlledDevice && !controlledDevice.IsRuined() && controlledDevice.GetArmed())
  45. return true;
  46. }
  47. return false;
  48. }
  49. override void OnFinishProgressServer(ActionData action_data)
  50. {
  51. ExplosivesBase explosive = ExplosivesBase.Cast(action_data.m_Target.GetObject());
  52. ItemBase detonator = ItemBase.Cast(action_data.m_MainItem);
  53. explosive.OnBeforeDisarm();
  54. //! claymore has integrated detonator
  55. if (explosive.IsInherited(ClaymoreMine))
  56. {
  57. explosive.Disarm();
  58. explosive.SetTakeable(true);
  59. detonator.Delete();
  60. return;
  61. }
  62. ReplaceDetonatorItemOnDisarmLambda lambda = new ReplaceDetonatorItemOnDisarmLambda(detonator, "RemoteDetonator");
  63. MiscGameplayFunctions.TurnItemIntoItemEx(action_data.m_Player, lambda);
  64. //! refresh IK, item changed
  65. action_data.m_Player.GetItemAccessor().OnItemInHandsChanged();
  66. }
  67. }