actionlockdoors.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. class ActionLockDoorsCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.LOCK);
  6. }
  7. };
  8. class ActionLockDoors: ActionContinuousBase
  9. {
  10. protected const float APPLIED_DMG = 6;
  11. void ActionLockDoors()
  12. {
  13. m_CallbackClass = ActionLockDoorsCB;
  14. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
  15. m_FullBody = true;
  16. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
  17. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_HIGH;
  18. m_Text = "#lock_door";
  19. }
  20. override void CreateConditionComponents()
  21. {
  22. m_ConditionItem = new CCINonRuined;
  23. m_ConditionTarget = new CCTCursor;
  24. }
  25. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  26. {
  27. if( !target ) return false;
  28. //if( IsDamageDestroyed(action_data.m_Target) ) return false;
  29. if( !IsBuilding(target) ) return false;
  30. if( !IsInReach(player, target, UAMaxDistances.DEFAULT) ) return false;
  31. Building building;
  32. if( Class.CastTo(building, target.GetObject()) )
  33. {
  34. int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
  35. if ( doorIndex != -1 )
  36. return building.CanDoorBeLocked(doorIndex);
  37. }
  38. return false;
  39. }
  40. protected void LockDoor(ActionTarget target)
  41. {
  42. Building building;
  43. if ( Class.CastTo(building, target.GetObject()) )
  44. {
  45. int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
  46. if ( doorIndex != -1 )
  47. {
  48. building.LockDoor(doorIndex);
  49. }
  50. }
  51. }
  52. override void OnFinishProgressServer( ActionData action_data )
  53. {
  54. LockDoor(action_data.m_Target);
  55. MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, APPLIED_DMG);
  56. }
  57. override bool IsLockTargetOnUse()
  58. {
  59. return false;
  60. }
  61. };