Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
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 if (m_ActionData.m_Player.GetInColdArea())
11 time_spent *= GameConstants.COLD_AREA_DIG_WORMS_MODIF;
12
13 m_ActionData.m_ActionComponent = new CAContinuousRepeat(time_spent);
14 }
15};
16
18{
19 void ActionDigWorms()
20 {
22 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGGIN_WORMS;
23 m_FullBody = true;
24 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
25 m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_MEDIUM;
26 m_Text = "#dig_up_worms";
27 }
28
29 override void CreateConditionComponents()
30 {
33 }
34
35 override bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
36 {
37 if (!super.Can(player, target, item, condition_mask))
38 return false;
39
40 return player.CheckFreeSpace(vector.Forward, 0.8, false);
41 }
42
43 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
44 {
45 if (player.IsPlacingLocal())
46 return false;
47
48 return IsTargetFertile(target) && IsPlayerOnGround(player);
49 }
50
51 override bool ActionConditionContinue(ActionData action_data)
52 {
53 return IsPlayerOnGround(action_data.m_Player);
54 }
55
56 override bool HasTarget()
57 {
58 return true;
59 }
60
61 override void OnFinishProgressServer(ActionData action_data)
62 {
63 int count = action_data.m_MainItem.GetOnDigWormsAmount();
64 for (int i = 0; i < count; i++)
65 {
66 /*
67 vector posHead;
68 MiscGameplayFunctions.GetHeadBonePos(action_data.m_Player,posHead);
69 vector posRandom = MiscGameplayFunctions.GetRandomizedPositionVerified(posHead,action_data.m_Target.GetCursorHitPos(),UAItemsSpreadRadius.NARROW,action_data.m_Player);
70
71 GetGame().CreateObjectEx("Worm", posRandom, ECE_PLACE_ON_SURFACE);
72 */
73 GetGame().CreateObjectEx("Worm", action_data.m_Target.GetCursorHitPos(), ECE_PLACE_ON_SURFACE);
74 }
75
76 MiscGameplayFunctions.DealEvinronmentAdjustedDmg(action_data.m_MainItem, action_data.m_Player, 4);
77 }
78
79 bool IsTargetFertile(ActionTarget target)
80 {
81 if (target)
82 {
83 string surface_type;
84 vector position;
85 position = target.GetCursorHitPos();
86
87 GetGame().SurfaceGetType(position[0], position[2], surface_type);
88
89 if (GetGame().IsSurfaceFertile(surface_type))
90 {
91 return true;
92 }
93 }
94
95 return false;
96 }
97
98 bool IsPlayerOnGround(PlayerBase player)
99 {
100 vector position = player.GetPosition();
101 float heightDiff = GetGame().SurfaceY(position[0], position[2]);
102 heightDiff = position[1] - heightDiff;
103
104 return heightDiff <= 0.4; // Player is considered on ground
105 }
106
108 void SetDiggignAnimation(ItemBase item);
109
110};
const int ECE_PLACE_ON_SURFACE
ActionData m_ActionData
float m_SpecialtyWeight
Definition actionbase.c:77
int m_StanceMask
Definition actionbase.c:62
string m_Text
Definition actionbase.c:58
ref CCIBase m_ConditionItem
Definition actionbase.c:64
bool m_FullBody
Definition actionbase.c:61
ref CCTBase m_ConditionTarget
Definition actionbase.c:65
proto native float SurfaceY(float x, float z)
proto float SurfaceGetType(float x, float z, out string type)
Returns: Y position the surface was found.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()