Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionharvestcrops.c
Go to the documentation of this file.
2 {
3  PlantBase m_Plant;
4 
5  void ActionHarvestCrops()
6  {
7 
8  m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_MEDIUM;
9  /*m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
10  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
11  m_FullBody = true;*/
12  }
13 
14  override typename GetInputType()
15  {
17  }
18 
19  Slot GetPlantSlot(ActionTarget target)
20  {
21  GardenBase garden_base;
22  if ( Class.CastTo(garden_base, target.GetObject()))
23  {
24  Slot slot;
25 
26  array<string> selections = new array<string>;
27  garden_base.GetActionComponentNameList(target.GetComponentIndex(), selections);
28  string selection;
29 
30  for (int s = 0; s < selections.Count(); s++)
31  {
32  selection = selections[s];
33  slot = garden_base.GetSlotBySelection( selection );
34  if (slot)
35  break;
36  }
37 
38  if ( slot && slot.GetPlant() )
39  {
40  return slot;
41  }
42  }
43  return null;
44  }
45 
46  override void OnActionInfoUpdate( PlayerBase player, ActionTarget target, ItemBase item )
47  {
48  m_Text = "#harvest";
49 
50  Slot slot = GetPlantSlot(target);
51 
52  if (slot)
53  {
54  m_Plant = PlantBase.Cast(slot.GetPlant());
55  m_Text+= " " + MiscGameplayFunctions.GetItemDisplayName(m_Plant.GetCropsType());
56  }
57 
58  }
59 
60  override void CreateConditionComponents()
61  {
64  }
65 
66  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
67  {
68  GardenBase garden_base;
69  if ( Class.CastTo(garden_base, target.GetObject()))
70  {
71  Slot slot = GetPlantSlot(target);
72 
73  if (slot)
74  {
75  m_Plant = PlantBase.Cast(slot.GetPlant());
76  bool is_mature = m_Plant.IsMature();
77  bool is_spoiled = m_Plant.IsSpoiled();
78  bool has_crops = m_Plant.HasCrops();
79  int plant_state = m_Plant.GetPlantState();
80 
81  if ( is_mature && has_crops )
82  {
83  return true;
84  }
85  }
86  }
87  return false;
88 
89  }
90 
91  override void OnExecuteServer( ActionData action_data )
92  {
93  if ( m_Plant )
94  {
95  m_Plant.Harvest( action_data.m_Player );
96 
97  action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
98  }
99  }
100 };
ItemBase
Definition: inventoryitem.c:730
ContinuousInteractActionInput
Definition: actioninput.c:521
UASoftSkillsWeight
Definition: actionconstants.c:118
CCINone
Definition: ccinone.c:1
UAMaxDistances
Definition: actionconstants.c:104
ActionInteractBase
Definition: actioninteractbase.c:54
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
CCTCursor
Definition: cctcursor.c:1
array< string >
ActionHarvestCrops
Definition: actionharvestcrops.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
GardenBase
Definition: gardenplot.c:1
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68