actionconsumesingle.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. class ActionConsumeSingleCB : ActionSingleUseBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CASingleUseQuantityEdible(UAQuantityConsumed.DEFAULT);
  6. }
  7. };
  8. class ActionConsumeSingle: ActionSingleUseBase
  9. {
  10. const int DEFAULT_CONSUMED_QUANTITY = 1;
  11. void ActionConsumeSingle()
  12. {
  13. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_LICKBATTERY;
  14. m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_LICKBATTERY;
  15. m_Text = "#eat";
  16. }
  17. int GetConsumedQuantity()
  18. {
  19. return DEFAULT_CONSUMED_QUANTITY;
  20. }
  21. override bool HasProneException()
  22. {
  23. return true;
  24. }
  25. override bool HasTarget()
  26. {
  27. return false;
  28. }
  29. override void CreateConditionComponents()
  30. {
  31. m_ConditionItem = new CCINotRuinedAndEmpty();
  32. m_ConditionTarget = new CCTSelf();
  33. }
  34. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  35. {
  36. return super.ActionCondition(player, target, item) && player.CanEatAndDrink();
  37. }
  38. override void OnExecuteServer(ActionData action_data)
  39. {
  40. PlayerBase player = action_data.m_Player;
  41. if (player && action_data.m_MainItem)
  42. player.Consume(action_data.m_MainItem, GetConsumedQuantity(), EConsumeType.ITEM_SINGLE_TIME);
  43. }
  44. override void OnEndServer(ActionData action_data)
  45. {
  46. super.OnEndServer(action_data);
  47. if (action_data.m_MainItem && (action_data.m_MainItem.GetQuantity() <= 0))
  48. action_data.m_MainItem.SetQuantity(0);
  49. if (action_data.m_Player.HasBloodyHandsEx() == eBloodyHandsTypes.SALMONELA && !action_data.m_Player.GetInventory().FindAttachment(InventorySlots.GLOVES) && GetProgress(action_data) > 0)
  50. action_data.m_Player.SetBloodyHandsPenalty();
  51. }
  52. }