DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionRemovePlant.c
Go to the documentation of this file.
2{
3 PlantBase m_Plant;
4
6 {
7 m_Text = "#remove_plant";
8 }
9
10 override typename GetInputType()
11 {
13 }
14
16 {
19 }
20
21 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
22 {
23 GardenBase garden_base;
24 if ( Class.CastTo(garden_base, target.GetObject()))
25 {
26 Slot slot;
27
28 array<string> selections = new array<string>;
29 garden_base.GetActionComponentNameList(target.GetComponentIndex(), selections);
30 string selection;
31
32 for (int s = 0; s < selections.Count(); s++)
33 {
34 selection = selections[s];
35 slot = garden_base.GetSlotBySelection( selection );
36 if (slot)
37 break;
38 }
39
40 if ( slot && slot.GetPlant() )
41 {
42 m_Plant = PlantBase.Cast(slot.GetPlant());
43 if ( m_Plant.IsGrowing() || m_Plant.IsDry() || !m_Plant.HasCrops() || m_Plant.IsSpoiled())
44 {
45 return true;
46 }
47 }
48 }
49 return false;
50 /*Object targetObject = target.GetObject();
51 if ( targetObject != NULL && targetObject.IsInherited(PlantBase) )
52 {
53 PlantBase plant = PlantBase.Cast( targetObject );
54
55 if ( plant.IsGrowing() || plant.IsDry() || !plant.HasCrops() || plant.IsSpoiled())
56 {
57 return true;
58 }
59 }
60
61 return false;*/
62 }
63
64 override void OnExecuteServer( ActionData action_data )
65 {
66 if ( m_Plant )
67 {
68 //m_Plant.RemovePlant();
69
70 //New method allowing us to pass player position
71 m_Plant.RemovePlantEx( action_data.m_Player.GetPosition() );
72 }
73 /*Object targetObject = action_data.m_Target.GetObject();
74 if ( targetObject != NULL && targetObject.IsInherited(PlantBase) )
75 {
76 PlantBase plant = PlantBase.Cast( targetObject );
77 plant.RemovePlant();
78 }*/
79 }
80};
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 CreateConditionComponents()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Super root of all classes in Enforce script.
Definition EnScript.c:11
const float SMALL
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.