actiondropitem.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. return player && item;
  54. }
  55. override void OnExecuteServer(ActionData action_data)
  56. {
  57. if (action_data.m_Player.IsPlacingServer())
  58. action_data.m_Player.PlacingCancelServer();
  59. ClearInventoryReservationEx(action_data);
  60. if (GetGame().IsServer() && GetGame().IsMultiplayer())
  61. {
  62. action_data.m_Player.ServerDropEntity(action_data.m_Player.GetItemInHands()); // multiplayer server side
  63. }
  64. else
  65. {
  66. PhysicalDropItem(action_data); // single player or multiplayer client side
  67. }
  68. }
  69. void PhysicalDropItem(ActionData action_data)
  70. {
  71. action_data.m_Player.PhysicalPredictiveDropItem(action_data.m_Player.GetItemInHands());
  72. }
  73. }