DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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
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
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};
protected float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
protected string m_Text
Definition ActionBase.c:49
class ActionTargets ActionTarget
PlayerBase m_Player
Definition ActionBase.c:33
override void OnExecuteServer(ActionData action_data)
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
override void CreateConditionComponents()
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
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.