Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionforceconsumesingle.c
Go to the documentation of this file.
2 {
3  override void CreateActionComponent()
4  {
5  m_ActionData.m_ActionComponent = new CASingleUseQuantityEdible(UAQuantityConsumed.DEFAULT);
6  }
7 }
8 
10 {
11  const int DEFAULT_CONSUMED_QUANTITY = 1;
12 
14  {
15  m_CallbackClass = ActionForceConsumeSingleCB;
16  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INJECTIONTARGET;
17  m_StanceMask = DayZPlayerConstants.STANCEIDX_ERECT | DayZPlayerConstants.STANCEIDX_CROUCH;
18  m_FullBody = true;
19  m_Text = "#feed";
20  }
21 
22  override void CreateConditionComponents()
23  {
26  }
27 
29  {
31  }
32 
33  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
34  {
35  if (!super.ActionCondition(player, target, item))
36  return false;
37 
38  if (item.GetQuantity() <= item.GetQuantityMin())
39  return false;
40 
41  PlayerBase targetPlayer = PlayerBase.Cast(target.GetObject());
42  return targetPlayer && targetPlayer.CanEatAndDrink();
43  }
44 
45  override void OnEndServer(ActionData action_data)
46  {
47  if (action_data.m_MainItem && action_data.m_MainItem.GetQuantity() <= 0)
48  {
49  action_data.m_MainItem.SetQuantity(0);
50  }
51 
52  if (action_data.m_Player.HasBloodyHands() && !action_data.m_Player.GetInventory().FindAttachment(InventorySlots.GLOVES))
53  {
54  PlayerBase target = PlayerBase.Cast(action_data.m_Target.GetObject());
55  if (target)
56  {
57  target.SetBloodyHandsPenalty();
58  }
59  }
60  }
61 
62  override void OnExecuteServer(ActionData action_data)
63  {
64  PlayerBase target = PlayerBase.Cast(action_data.m_Target.GetObject());
65 
66  if (target && action_data.m_MainItem)
67  {
68  target.Consume(action_data.m_MainItem, GetConsumedQuantity(), EConsumeType.ITEM_SINGLE_TIME);
69  }
70  }
71 }
ItemBase
Definition: inventoryitem.c:730
CASingleUseQuantityEdible
Definition: casingleusequantityedible.c:1
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
GetConsumedQuantity
int GetConsumedQuantity()
Definition: actionforceconsumesingle.c:28
CCTMan
Definition: cctman.c:1
UAQuantityConsumed
Definition: actionconstants.c:3
ActionForceConsumeSingle
void ActionForceConsumeSingle()
Definition: actionforceconsumesingle.c:13
CreateConditionComponents
override void CreateConditionComponents()
Definition: actionforceconsumesingle.c:22
DEFAULT_CONSUMED_QUANTITY
ActionForceConsumeSingleCB DEFAULT_CONSUMED_QUANTITY
ActionSingleUseBaseCB
Definition: actionsingleusebase.c:1
UAMaxDistances
Definition: actionconstants.c:104
OnExecuteServer
override void OnExecuteServer(ActionData action_data)
Definition: actionforceconsumesingle.c:62
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
EConsumeType
EConsumeType
Definition: econsumetype.c:1
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition: actionforceconsumesingle.c:33
OnEndServer
override void OnEndServer(ActionData action_data)
Definition: actionforceconsumesingle.c:45
m_Text
protected string m_Text
Definition: actionbase.c:49
ActionSingleUseBase
Definition: actionsingleusebase.c:41
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionForceConsumeSingleCB
Definition: actionforceconsumesingle.c:1
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53