Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionplantseed.c
Go to the documentation of this file.
2 {
3  void ActionPlantSeed()
4  {
5  m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_MEDIUM;
6 
7  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_DROPITEM_HANDS;
8  m_FullBody = false;
9  m_Text = "#plant_seed";
10  }
11 
12  override void CreateConditionComponents()
13  {
16  }
17 
18  override bool HasTarget()
19  {
20  return true;
21  }
22 
23  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
24  {
25  GardenBase targetObject = GardenBase.Cast( target.GetObject() );
26 
27  if ( targetObject && ( !targetObject.IsHologram() || !targetObject.IsBeingPlaced() ) )
28  {
29  array<string> selections = new array<string>;
30  targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections);
31 
32  for (int s = 0; s < selections.Count(); s++)
33  {
34  string selection = selections[s];
35  Slot slot = targetObject.GetSlotBySelection( selection );
36  if (slot)
37  {
38  if ( item != NULL && item.GetQuantity() > 0 && targetObject.CanPlantSeed( selection ) )
39  {
40  return true;
41  }
42  }
43  }
44  }
45 
46  return false;
47  }
48 
49  override void OnExecuteServer( ActionData action_data )
50  {
51  Process(action_data);
52  }
53 
54  override void OnExecuteClient( ActionData action_data )
55  {
56  //Process(action_data);
57  }
58 
59  void Process( ActionData action_data )
60  {
61  Object targetObject = action_data.m_Target.GetObject();
62  int slot_ID;
63 
64  if ( targetObject != NULL && targetObject.IsInherited(GardenBase) )
65  {
66  GardenBase garden_base = GardenBase.Cast( targetObject );
67  array<string> selections = new array<string>;
68  targetObject.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
69 
70  for (int s = 0; s < selections.Count(); s++)
71  {
72  string selection = selections[s];
73  Slot slot = garden_base.GetSlotBySelection( selection );
74  if (slot)
75  {
76  slot_ID = slot.GetSlotId();
77  break;
78  }
79  }
80 
81  //int slot_ID = slot.GetSlotId();
82 
83  ItemBase seed_IB = ItemBase.Cast( action_data.m_MainItem );
84 
85  seed_IB.SplitIntoStackMax( garden_base, slot_ID, action_data.m_Player );
86  }
87 
88  action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
89  }
90 };
ItemBase
Definition: inventoryitem.c:730
UASoftSkillsWeight
Definition: actionconstants.c:118
ActionPlantSeed
Definition: actionplantseed.c:1
CCTDummy
Definition: cctdummy.c:1
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
Object
Definition: objecttyped.c:1
array< string >
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
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
GardenBase
Definition: gardenplot.c:1
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68