DayZ 1.24
Loading...
Searching...
No Matches
ActionBuildShelter.c
Go to the documentation of this file.
2{
7
9 {
11 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_2HD;
12 m_FullBody = true;
13 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
14 m_Text = "#build_shelter_leather";
15 }
16
21
23 {
26 }
27
28 override string GetText()
29 {
31 if (player)
32 {
33 ConstructionActionData construction_action_data = player.GetConstructionActionData();
35
37 {
38 string ret = "";
39 switch (constrution_part.GetName())
40 {
41 case "leather":
42 ret = "#build_shelter_leather";
43 break;
44
45 case "fabric":
46 ret = "#build_shelter_fabric";
47 break;
48
49 case "stick":
50 ret = "#build_shelter_stick";
51 break;
52 }
53 }
54 }
55
56 return ret;
57 }
58
60 {
61 ConstructionActionData construction_action_data = player.GetConstructionActionData();
63
65 {
66 switch (constrution_part.GetName())
67 {
68 case "leather":
69 m_Text = "#build_shelter_leather";
70 break;
71
72 case "fabric":
73 m_Text = "#build_shelter_fabric";
74 break;
75
76 case "stick":
77 m_Text = "#build_shelter_stick";
78 break;
79 }
80 }
81 }
82
83 override bool CanBeUsedLeaning()
84 {
85 return false;
86 }
87
88 override typename GetInputType()
89 {
91 }
92
93 override bool UseMainItem()
94 {
95 return false;
96 }
97
98 override bool HasProgress()
99 {
100 return true;
101 }
102
104 {
105 return false;
106 }
107
108 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
109 {
110 //Action not allowed if player has broken legs
111 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
112 return false;
113
114 if (target.GetObject() && !target.GetObject().CanUseConstructionBuild())
115 return false;
116 if (player.IsPlacingLocal() || player.IsPlacingServer())
117 return false;
118
119 if ((!GetGame().IsDedicatedServer()))
120 {
121 if (MiscGameplayFunctions.ComplexBuildCollideCheckClient(player, target, item, m_VariantID))
122 return true;
123 return false;
124 }
125 return true;
126 }
127
128 //setup
130 {
131 if (super.SetupAction(player, target, item, action_data, extra_data))
132 {
133 if (!GetGame().IsDedicatedServer())
134 {
135 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
136 BuildPartActionData.Cast(action_data).m_PartType = construction_action_data.GetBuildPartNoToolAtIndex(m_VariantID).GetPartName();
137 }
138 return true;
139 }
140
141 return false;
142 }
143
149
151 {
152 super.WriteToContext(ctx, action_data);
153
154 ctx.Write(BuildPartActionData.Cast(action_data).m_PartType);
155 }
156
158 {
160 super.ReadFromContext(ctx, action_recive_data);
161
162 string part_type;
163 if (ctx.Read(part_type))
164 {
166 return true;
167 }
168 else
169 return false;
170 }
171
178
180 {
181 BaseBuildingBase base_building = BaseBuildingBase.Cast(action_data.m_Target.GetObject());
182 Construction construction = base_building.GetConstruction();
183 string part_name = BuildPartActionData.Cast(action_data).m_PartType;
185
186 check_data.m_PartName = part_name;
187 check_data.m_AdditionalExcludes.Insert(action_data.m_Player);
188
189 return !construction.IsCollidingEx(check_data) && construction.CanBuildPart(part_name, action_data.m_MainItem, false);
190 }
191
193 {
194 super.OnStart(action_data);
195 action_data.m_Player.TryHideItemInHands(true);
196 }
197
205
207 {
208 super.OnStartAnimationLoopClient(action_data);
209
211 }
212
214 {
215 super.OnEnd(action_data);
216 action_data.m_Player.TryHideItemInHands(false);
217 }
218
220 {
221 super.OnEndClient(action_data);
222
224 //DestroyActionLoopSound();
225 }
226
228 {
229 BaseBuildingBase base_building = BaseBuildingBase.Cast(action_data.m_Target.GetObject());
230 Construction construction = base_building.GetConstruction();
231
232 string part_name = BuildPartActionData.Cast(action_data).m_PartType;
233
234 if (!construction.IsColliding(part_name) && construction.CanBuildPart(part_name, action_data.m_MainItem, false))
235 {
236 //build
237 construction.BuildPartServer(action_data.m_Player, part_name, AT_BUILD_PART);
238 }
239
240 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
241 }
242
244 {
245 super.OnFinishProgressClient(action_data);
246
248 }
249
251 {
252 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
255 {
256 switch (constrution_part.GetName())
257 {
258 case "leather":
259 m_SoundsetBuildStart = "Shelter_Leather_Build_Start_SoundSet";
260 m_SoundsetBuildLoop = "Shelter_Leather_Build_Loop_SoundSet";
261 m_SoundsetBuildFinish = "Shelter_Leather_Build_Finish_SoundSet";
262 break;
263
264 case "fabric":
265 m_SoundsetBuildStart = "Shelter_Fabric_Build_Start_SoundSet";
266 m_SoundsetBuildLoop = "Shelter_Fabric_Build_Loop_SoundSet";
267 m_SoundsetBuildFinish = "Shelter_Fabric_Build_Finish_SoundSet";
268 break;
269
270 case "stick":
271 m_SoundsetBuildStart = "Shelter_Wooden_Stick_Build_Start_SoundSet";
272 m_SoundsetBuildLoop = "Shelter_Wooden_Stick_Build_Loop_SoundSet";
273 m_SoundsetBuildFinish = "Shelter_Wooden_Stick_Build_Finish_SoundSet";
274 break;
275
276 default:
280 break;
281 }
282 }
283 }
284
286 {
287 EffectSound sound = SEffectManager.PlaySound(m_SoundsetBuildStart, action_data.m_Target.GetObject().GetPosition());
288 sound.SetAutodestroy(true);
289 }
290
296
298 {
300 {
303 }
304 }
305
310
312 {
313 EffectSound sound = SEffectManager.PlaySound(m_SoundsetBuildFinish, action_data.m_Target.GetObject().GetPosition());
314 sound.SetAutodestroy(true);
315 }
316
318 {
319 return "Base_building";
320 }
321}
const int AT_BUILD_PART
Definition _constants.c:6
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
int m_VariantID
Definition ActionBase.c:59
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
void CollisionCheckData()
void Construction(BaseBuildingBase parent)
eBrokenLegs
Definition EBrokenLegs.c:2
PlayerBase GetPlayer()
void DetermineConstructionSounds(ActionData action_data)
override bool UseMainItem()
void PlayActionLoopSound(ActionData action_data)
override string GetSoundCategory(ActionData action_data)
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnEndClient(ActionData action_data)
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
override bool ActionConditionContinue(ActionData action_data)
override void OnStartAnimationLoopClient(ActionData action_data)
override void OnEnd(ActionData action_data)
override bool HasAlternativeInterrupt()
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
override void OnStart(ActionData action_data)
override void OnStartClient(ActionData action_data)
override bool CanBeUsedLeaning()
override void OnFinishProgressServer(ActionData action_data)
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
void PlayActionStartSound(ActionData action_data)
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
override void OnFinishProgressClient(ActionData action_data)
override void CreateConditionComponents()
override string GetText()
EffectSound m_BuildLoopSound
void PlayActionFinishSound(ActionData action_data)
override ActionData CreateActionData()
override bool HasProgress()
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
void SetSoundFadeOut(float fade_out)
Set the sound fade out duration.
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
void SoundStop()
Stops sound.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Manager class for managing Effect (EffectParticle, EffectSound)
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()