Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiondigworms.c
Go to the documentation of this file.
2 {
3  override void CreateActionComponent()
4  {
5  float time_spent;
6  time_spent = UATimeSpent.DIG_WORMS;
7  if (m_ActionData.m_MainItem.KindOf("Knife"))
8  time_spent = time_spent * 1.2;
9 
10  m_ActionData.m_ActionComponent = new CAContinuousTime(time_spent);
11  }
12 };
13 
15 {
16  void ActionDigWorms()
17  {
18  m_CallbackClass = ActionDigWormsCB;
19  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGMANIPULATE;
20  m_FullBody = true;
21  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
23  m_Text = "#dig_up_worms";
24  }
25 
26  override void CreateConditionComponents()
27  {
30  }
31 
32  override bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
33  {
34  if (!super.Can(player, target, item, condition_mask))
35  return false;
36 
37  return player.CheckFreeSpace(vector.Forward, 0.8, false);
38  }
39 
40  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
41  {
42  if (player.IsPlacingLocal())
43  return false;
44 
45  return IsTargetFertile(target) && IsPlayerOnGround(player);
46  }
47 
48  override bool ActionConditionContinue(ActionData action_data)
49  {
50  return IsPlayerOnGround(action_data.m_Player);
51  }
52 
53  override bool SetupAction( PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL )
54  {
55  if (super.SetupAction(player, target, item, action_data, extra_data))
56  {
57  if (item)
58  {
59  SetDiggingAnimation(item);
60  }
61 
62  return true;
63  }
64 
65  return false;
66  }
67 
68  override bool HasTarget()
69  {
70  return true;
71  }
72 
73  override void OnFinishProgressServer(ActionData action_data)
74  {
75  ItemBase worms;
76  Class.CastTo(worms, GetGame().CreateObjectEx("Worm", action_data.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE));
77  worms.SetQuantity(10,false);
78  MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, 4);
79  action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
80  }
81 
82  void SetDiggingAnimation( ItemBase item )
83  {
84  if (item.KindOf("Knife"))
85  {
86  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_1HD;
87  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
88  }
89  else
90  {
91  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGMANIPULATE;
92  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
93  }
94  }
95 
96  bool IsTargetFertile(ActionTarget target)
97  {
98  if (target)
99  {
100  string surface_type;
101  vector position;
102  position = target.GetCursorHitPos();
103 
104  GetGame().SurfaceGetType(position[0], position[2], surface_type);
105 
106  if (GetGame().IsSurfaceFertile(surface_type))
107  {
108  return true;
109  }
110  }
111 
112  return false;
113  }
114 
115  bool IsPlayerOnGround(PlayerBase player)
116  {
117  vector position = player.GetPosition();
118  float heightDiff = GetGame().SurfaceY(position[0], position[2]);
119  heightDiff = position[1] - heightDiff;
120 
121  return heightDiff <= 0.4; // Player is considered on ground
122  }
123 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
CAContinuousTime
Definition: cacontinuoustime.c:1
UASoftSkillsWeight
Definition: actionconstants.c:118
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
UAMaxDistances
Definition: actionconstants.c:104
ActionDigWormsCB
Definition: actiondigworms.c:1
ActionDigWorms
Definition: actiondigworms.c:14
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
UATimeSpent
Definition: actionconstants.c:26
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
CCTSurface
Definition: cctsurface.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53