actiondisarmexplosive.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. class ActionDisarmExplosiveCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.DISARM_MINE);
  6. }
  7. }
  8. class ActionDisarmExplosive : ActionContinuousBase
  9. {
  10. void ActionDisarmExplosive()
  11. {
  12. m_CallbackClass = ActionDisarmExplosiveCB;
  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. ExplosivesBase explosive;
  30. if (Class.CastTo(explosive, target.GetObject()) && item)
  31. {
  32. return explosive.GetArmed() && explosive.CanBeDisarmed();
  33. }
  34. return false;
  35. }
  36. override void OnFinishProgressServer(ActionData action_data)
  37. {
  38. ExplosivesBase explosive = ExplosivesBase.Cast(action_data.m_Target.GetObject());
  39. ToolBase tool = ToolBase.Cast(action_data.m_MainItem);
  40. if (Math.RandomIntInclusive(0, 100) < tool.GetDisarmRate())
  41. {
  42. explosive.OnBeforeDisarm();
  43. explosive.Disarm(true);
  44. }
  45. else
  46. {
  47. explosive.SetHealth("", "", 0.0);
  48. }
  49. MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, UADamageApplied.DEFUSE_TOOLS);
  50. }
  51. }