actiondropitem.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. class ActionDropItemCB : ActionSingleUseBaseCB
  2. {
  3. override void EndActionComponent()
  4. {
  5. SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
  6. m_ActionData.m_State = UA_FINISHED;
  7. }
  8. }
  9. class ActionDropItem : ActionSingleUseBase
  10. {
  11. string m_ItemName = "";
  12. void ActionDropItem()
  13. {
  14. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_DROPITEM_HANDS;
  15. m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_DROPITEM_HANDS;
  16. m_CallbackClass = ActionDropItemCB;
  17. m_Text = "#drop_item";
  18. }
  19. override void CreateConditionComponents()
  20. {
  21. m_ConditionItem = new CCINone();
  22. m_ConditionTarget = new CCTNone();
  23. }
  24. override typename GetInputType()
  25. {
  26. return DropActionInput;
  27. }
  28. override bool HasProneException()
  29. {
  30. return true;
  31. }
  32. override bool CanBeUsedThrowing()
  33. {
  34. return true;
  35. }
  36. override bool HasTarget()
  37. {
  38. return false;
  39. }
  40. override bool UseAcknowledgment()
  41. {
  42. return false;
  43. }
  44. override bool ActionConditionContinue(ActionData action_data)
  45. {
  46. return true;
  47. }
  48. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  49. {
  50. HumanCommandMove hcm = player.GetCommand_Move();
  51. if (hcm && hcm.IsChangingStance())
  52. return false;
  53. if (player.GetCommand_Vehicle())
  54. return false;
  55. return player && item;
  56. }
  57. override void OnExecuteServer(ActionData action_data)
  58. {
  59. if (action_data.m_Player.IsPlacingServer())
  60. action_data.m_Player.PlacingCancelServer();
  61. if (!GetGame().IsMultiplayer())
  62. {
  63. ClearInventoryReservationEx(action_data);
  64. PhysicalDropItem(action_data);
  65. }
  66. }
  67. override void OnExecuteClient(ActionData action_data)
  68. {
  69. super.OnExecuteClient(action_data);
  70. ClearInventoryReservationEx(action_data);
  71. PhysicalDropItem(action_data);
  72. }
  73. void PhysicalDropItem( ActionData action_data )
  74. {
  75. action_data.m_Player.PhysicalPredictiveDropItem(action_data.m_Player.GetItemInHands());
  76. }
  77. }