Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionrepacktent.c
Go to the documentation of this file.
2 {
3  override void CreateActionComponent()
4  {
5  m_ActionData.m_ActionComponent = new CAContinuousTime( UATimeSpent.UNPACK );
6  }
7 
8  void DropDuringRepacking()
9  {
10  vector orientation = m_ActionData.m_Player.GetOrientation();
11  vector position = m_ActionData.m_Player.GetPosition() + m_ActionData.m_Player.GetDirection();
12  vector rotation_matrix[3];
13  float direction[4];
15  InventoryLocation destination = new InventoryLocation;
16 
17  Math3D.YawPitchRollMatrix( orientation, rotation_matrix );
18  Math3D.MatrixToQuat( rotation_matrix, direction );
19 
20  vector ground_position = position;
21  ground_position[1] = GetGame().SurfaceY(ground_position[0],ground_position[2]);
22 
23  if ( vector.DistanceSq( m_ActionData.m_Player.GetPosition(), ground_position ) > UAMaxDistances.DEFAULT * UAMaxDistances.DEFAULT)
24  {
25  if ( m_ActionData.m_MainItem.GetInventory().GetCurrentInventoryLocation( source ) )
26  {
27  destination.SetGroundEx( m_ActionData.m_MainItem, position, direction );
28  m_ActionData.m_Player.PredictiveTakeToDst(source, destination);
29  }
30  }
31  else
32  {
33  if ( m_ActionData.m_MainItem.GetInventory().GetCurrentInventoryLocation( source ) )
34  {
35  destination.SetGroundEx( m_ActionData.m_MainItem, ground_position, direction );
36  m_ActionData.m_Player.PredictiveTakeToDst(source, destination);
37  }
38  }
39  }
40 };
41 
43 {
44  EntityAI m_RepackedEntity;
45  bool m_IsFinished;
46 
47  void ActionRepackTent()
48  {
49  m_CallbackClass = ActionRepackTentCB;
51  m_CommandUID = 0;
52  m_FullBody = true;
53  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
54  m_Text = "#repack_tent";
55  }
56 
57  override void CreateConditionComponents()
58  {
61  }
62 
63  override bool HasTarget()
64  {
65  return false;
66  }
67 
68  override bool HasProgress()
69  {
70  return true;
71  }
72 
73  override bool ActionConditionContinue( ActionData action_data )
74  {
75  return true;
76  }
77 
78  override bool HasAlternativeInterrupt()
79  {
80  return true;
81  }
82 
83  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
84  {
85  if ( !player.IsPlacingLocal() )
86  {
87  return true;
88  }
89  return false;
90  }
91 
92  override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL)
93  {
94  SetupAnimation( item );
95 
96  if ( super.SetupAction(player, target, item, action_data, extra_data ))
97  {
98  return true;
99  }
100  return false;
101  }
102 
103  override void OnStartServer( ActionData action_data )
104  {
105  m_RepackedEntity = null;
106  m_IsFinished = false;
107  }
108 
109  override void OnFinishProgressServer( ActionData action_data )
110  {
111  Param1<bool> play = new Param1<bool>( false );
112  GetGame().RPCSingleParam( action_data.m_MainItem, SoundTypeTent.REPACK, play, true );
113 
114  m_IsFinished = true;
115  }
116 
117  override void OnEndServer( ActionData action_data )
118  {
119  if ( m_IsFinished )
120  {
121  if ( action_data.m_MainItem.IsInherited( TentBase ) )
122  {
123  RepackLambda lambda_back_pack = new RepackLambda(action_data.m_MainItem, "LargeTentBackPack", action_data.m_Player);
124  action_data.m_Player.ServerReplaceItemElsewhereWithNewInHands(lambda_back_pack);
125  }
126 
127  if ( action_data.m_MainItem.IsInherited( Clothing ) )
128  {
129  RepackLambda lambda_tent = new RepackLambda(action_data.m_MainItem, "LargeTent", action_data.m_Player);
130  action_data.m_Player.ServerReplaceItemElsewhereWithNewInHands(lambda_tent);
131  }
132  }
133  else
134  {
135  if ( GetGame().IsMultiplayer() )
136  {
137  if ( action_data.m_MainItem )
138  {
139  action_data.m_Player.ServerTakeEntityToHands( action_data.m_MainItem );
140  }
141  }
142  else
143  {
144  if ( action_data.m_MainItem )
145  {
146  action_data.m_Player.LocalTakeEntityToHands( action_data.m_MainItem );
147  }
148  }
149  }
150  }
151 
152  void SetupAnimation( ItemBase item )
153  {
154  if ( item.IsHeavyBehaviour() )
155  {
156  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_HEAVY;
157  }
158  else if ( item.IsOneHandedBehaviour() )
159  {
160  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_1HD;
161  }
162  else if ( item.IsTwoHandedBehaviour() )
163  {
164  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_2HD;
165  }
166  else
167  {
168  Print("Error: check " + item + " behaviour");
169  }
170  }
171 
172  override void OnStartAnimationLoopClient( ActionData action_data )
173  {
174  if ( action_data.m_Player.GetItemInHands() )
175  ActionRepackTentCB.Cast(action_data.m_Callback).DropDuringRepacking();
176  }
177 
178  override void OnStartAnimationLoopServer( ActionData action_data )
179  {
180  Param1<bool> play = new Param1<bool>( false );
181  if ( !GetGame().IsMultiplayer() )
182  {
183  if ( action_data.m_Player.GetItemInHands() )
184  ActionRepackTentCB.Cast(action_data.m_Callback).DropDuringRepacking();
185  }
186 
187  if ( action_data.m_Player.GetItemInHands() )
188  {
189  play = new Param1<bool>( true );
190  GetGame().RPCSingleParam( action_data.m_MainItem, SoundTypeTent.REPACK, play, true );
191  }
192  }
193 
194  override void OnEndAnimationLoop( ActionData action_data )
195  {
196  if ( !GetGame().IsMultiplayer() || GetGame().IsServer() )
197  {
198  Param1<bool> play = new Param1<bool>( false );
199  GetGame().RPCSingleParam( action_data.m_MainItem, SoundTypeTent.REPACK, play, true );
200  }
201  }
202 
203  override string GetAdminLogMessage(ActionData action_data)
204  {
205  return " re-packed " + action_data.m_Target.GetObject().GetDisplayName() + " with Hands ";
206  }
207 };
208 
210 {
211  EntityAI m_RepackedNewEntity;
212 
213  void RepackLambda (EntityAI old_item, string new_item_type, PlayerBase player)
214  {
216  hands.SetHands( player, null );
217  OverrideNewLocation( hands );
218  }
219 };
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
CCINone
Definition: ccinone.c:1
Print
proto void Print(void var)
Prints content of variable to console/log.
SoundTypeTent
SoundTypeTent
Definition: largetent.c:1
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
CCTNone
Definition: cctnone.c:1
RepackLambda
Definition: actionrepacktent.c:209
ActionRepackTentCB
Definition: actionrepacktent.c:1
UAMaxDistances
Definition: actionconstants.c:104
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
Clothing
Definition: armband_colorbase.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
TentBase
Definition: cartent.c:1
UATimeSpent
Definition: actionconstants.c:26
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
ActionRepackTent
Definition: actionrepacktent.c:42
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
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
TurnItemIntoItemLambda
Definition: miscgameplayfunctions.c:91
EntityAI
Definition: building.c:5
Math3D
Definition: enmath3d.c:27