actionpacktent.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. class ActionPackTentCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.DEFAULT_DEPLOY); //Use same time as Deploy
  6. }
  7. }
  8. class ActionPackTent : ActionContinuousBase
  9. {
  10. void ActionPackTent()
  11. {
  12. m_CallbackClass = ActionPackTentCB;
  13. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
  14. m_CommandUID = 0;
  15. m_FullBody = true;
  16. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
  17. m_Text = "#pack_tent";
  18. }
  19. override void CreateConditionComponents()
  20. {
  21. m_ConditionItem = new CCINone;
  22. m_ConditionTarget = new CCTCursorParent(UAMaxDistances.DEFAULT);
  23. }
  24. override typename GetInputType()
  25. {
  26. return ContinuousInteractActionInput;
  27. }
  28. override bool IsUsingProxies()
  29. {
  30. return true;
  31. }
  32. override bool HasProgress()
  33. {
  34. return true;
  35. }
  36. override bool HasAlternativeInterrupt()
  37. {
  38. return true;
  39. }
  40. override bool UseMainItem()
  41. {
  42. return false;
  43. }
  44. override bool ActionConditionContinue( ActionData action_data )
  45. {
  46. Object targetParent = action_data.m_Target.GetParent();
  47. TentBase tent = TentBase.Cast( targetParent );
  48. return tent.CanBePacked();
  49. }
  50. override ActionData CreateActionData()
  51. {
  52. PlaceObjectActionData action_data = new PlaceObjectActionData;
  53. return action_data;
  54. }
  55. override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL)
  56. {
  57. if ( super.SetupAction(player, target, item, action_data, extra_data ))
  58. {
  59. PlaceObjectActionData poActionData;
  60. poActionData = PlaceObjectActionData.Cast(action_data);
  61. poActionData.m_AlreadyPlaced = false;
  62. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_2HD; //Call the animation
  63. return true;
  64. }
  65. return false;
  66. }
  67. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  68. {
  69. Object targetObject = target.GetObject();
  70. Object targetParent = target.GetParent();
  71. TentBase inventory_tent = TentBase.Cast(targetObject);
  72. if (inventory_tent && inventory_tent.GetHierarchyRootPlayer())
  73. {
  74. return false; //tent is somewhere in player's inventory
  75. }
  76. if ( player && targetObject && targetParent )
  77. {
  78. TentBase tent = TentBase.Cast( targetParent );
  79. if ( tent.CanBePacked() )
  80. {
  81. array<string> selections = new array<string>;
  82. targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections);
  83. for ( int s = 0; s < selections.Count(); s++ )
  84. {
  85. if ( selections[s] == "pack" )
  86. {
  87. return true;
  88. }
  89. }
  90. }
  91. }
  92. return false;
  93. }
  94. override void Start( ActionData action_data ) //Setup on start of action
  95. {
  96. super.Start(action_data);
  97. if ( action_data.m_Player ) action_data.m_Player.TryHideItemInHands(true);
  98. }
  99. override void OnExecute( ActionData action_data )
  100. {
  101. Object targetParent = action_data.m_Target.GetParent();
  102. TentBase tent = TentBase.Cast( targetParent );
  103. tent.SetIsBeingPacked(true);
  104. }
  105. override void OnEnd( ActionData action_data )
  106. {
  107. Object targetParent = action_data.m_Target.GetParent();
  108. TentBase tent = TentBase.Cast( targetParent );
  109. tent.SetIsBeingPacked(false);
  110. if ( action_data.m_Player ) action_data.m_Player.TryHideItemInHands(false);
  111. }
  112. override void OnFinishProgressServer( ActionData action_data )
  113. {
  114. //vector offset = Vector(1, 0, 0);
  115. Object targetParent = action_data.m_Target.GetParent();
  116. TentBase tent = TentBase.Cast( targetParent );
  117. if (tent.CanBePacked())
  118. tent.Pack(true);
  119. }
  120. override string GetAdminLogMessage(ActionData action_data)
  121. {
  122. return " packed " + action_data.m_Target.GetParent().GetDisplayName() + " with Hands ";
  123. }
  124. };