DayZ 1.24
Loading...
Searching...
No Matches
ActionHarvestCrops.c
Go to the documentation of this file.
2{
3 PlantBase m_Plant;
4
6 {
7
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 {
22 if (Class.CastTo(garden_base, target.GetObject()))
23 {
24 Slot slot;
25
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 return slot;
40 }
41 return null;
42 }
43
45 {
46 m_Text = "#harvest";
47
48 Slot slot = GetPlantSlot(target);
49
50 if (slot)
51 {
52 m_Plant = PlantBase.Cast(slot.GetPlant());
53 m_Text += " " + MiscGameplayFunctions.GetItemDisplayName(m_Plant.GetCropsType());
54 }
55
56 }
57
63
64 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
65 {
67 if (Class.CastTo(garden_base, target.GetObject()))
68 {
69 Slot slot = GetPlantSlot(target);
70
71 if (slot)
72 {
73 m_Plant = PlantBase.Cast(slot.GetPlant());
74 bool is_mature = m_Plant.IsMature();
75 bool is_spoiled = m_Plant.IsSpoiled();
76 bool has_crops = m_Plant.HasCrops();
77 int plant_state = m_Plant.GetPlantState();
78
79 if (is_mature && has_crops)
80 return true;
81 }
82 }
83 return false;
84
85 }
86
88 {
89 if (m_Plant)
90 {
91 m_Plant.Harvest(action_data.m_Player);
92
93 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
94 }
95 }
96};
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
override void OnExecuteServer(ActionData action_data)
override void CreateConditionComponents()
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Slot GetPlantSlot(ActionTarget target)
Super root of all classes in Enforce script.
Definition EnScript.c:11
const float SMALL
const float PRECISE_MEDIUM
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.