Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
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
44{
45 EntityAI m_RepackedEntity;
46 bool m_IsFinished;
47
48 void ActionRepackTent()
49 {
51 m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
52 m_CommandUID = 0;
53 m_FullBody = true;
54 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
55 m_Text = "#repack_tent";
56 }
57
58 override void CreateConditionComponents()
59 {
62 }
63
64 override bool HasTarget()
65 {
66 return false;
67 }
68
69 override bool HasProgress()
70 {
71 return true;
72 }
73
74 override bool ActionConditionContinue( ActionData action_data )
75 {
76 return true;
77 }
78
79 override bool HasAlternativeInterrupt()
80 {
81 return true;
82 }
83
84 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
85 {
86 if ( !player.IsPlacingLocal() )
87 {
88 return true;
89 }
90 return false;
91 }
92
93 override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL)
94 {
95 SetupAnimation( item );
96
97 if ( super.SetupAction(player, target, item, action_data, extra_data ))
98 {
99 return true;
100 }
101 return false;
102 }
103
104 override void OnStartServer( ActionData action_data )
105 {
106 super.OnStartServer(action_data);
107
108 m_RepackedEntity = null;
109 m_IsFinished = false;
110 }
111
112 override void OnFinishProgressServer( ActionData action_data )
113 {
114 Param1<bool> play = new Param1<bool>( false );
115 GetGame().RPCSingleParam( action_data.m_MainItem, SoundTypeTent.REPACK, play, true );
116
117 m_IsFinished = true;
118 }
119
120 override void OnEndServer( ActionData action_data )
121 {
122 super.OnEndServer(action_data);
123
124 if ( m_IsFinished )
125 {
126 if ( action_data.m_MainItem.IsInherited( TentBase ) )
127 {
128 RepackLambda lambda_back_pack = new RepackLambda(action_data.m_MainItem, "LargeTentBackPack", action_data.m_Player);
129 action_data.m_Player.ServerReplaceItemElsewhereWithNewInHands(lambda_back_pack);
130 }
131
132 if ( action_data.m_MainItem.IsInherited( Clothing ) )
133 {
134 RepackLambda lambda_tent = new RepackLambda(action_data.m_MainItem, "LargeTent", action_data.m_Player);
135 action_data.m_Player.ServerReplaceItemElsewhereWithNewInHands(lambda_tent);
136 }
137 }
138 else
139 {
140 if ( GetGame().IsMultiplayer() )
141 {
142 if ( action_data.m_MainItem )
143 {
144 action_data.m_Player.ServerTakeEntityToHands( action_data.m_MainItem );
145 }
146 }
147 else
148 {
149 if ( action_data.m_MainItem )
150 {
151 action_data.m_Player.LocalTakeEntityToHands( action_data.m_MainItem );
152 }
153 }
154 }
155 }
156
157 void SetupAnimation( ItemBase item )
158 {
159 if ( item.IsHeavyBehaviour() )
160 {
161 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_HEAVY;
162 }
163 else if ( item.IsOneHandedBehaviour() )
164 {
165 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_1HD;
166 }
167 else if ( item.IsTwoHandedBehaviour() )
168 {
169 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_2HD;
170 }
171 else
172 {
173 Print("Error: check " + item + " behaviour");
174 }
175 }
176
177 override void OnStartAnimationLoopClient( ActionData action_data )
178 {
179 if ( action_data.m_Player.GetItemInHands() )
180 ActionRepackTentCB.Cast(action_data.m_Callback).DropDuringRepacking();
181 }
182
183 override void OnStartAnimationLoopServer( ActionData action_data )
184 {
185 Param1<bool> play = new Param1<bool>( false );
186 if ( !GetGame().IsMultiplayer() )
187 {
188 if ( action_data.m_Player.GetItemInHands() )
189 ActionRepackTentCB.Cast(action_data.m_Callback).DropDuringRepacking();
190 }
191
192 if ( action_data.m_Player.GetItemInHands() )
193 {
194 play = new Param1<bool>( true );
195 GetGame().RPCSingleParam( action_data.m_MainItem, SoundTypeTent.REPACK, play, true );
196 }
197 }
198
199 override void OnEndAnimationLoop( ActionData action_data )
200 {
201 if ( !GetGame().IsMultiplayer() || GetGame().IsServer() )
202 {
203 Param1<bool> play = new Param1<bool>( false );
204 GetGame().RPCSingleParam( action_data.m_MainItem, SoundTypeTent.REPACK, play, true );
205 }
206 }
207
208 override string GetAdminLogMessage(ActionData action_data)
209 {
210 return " re-packed " + action_data.m_Target.GetObject().GetDisplayName() + " with Hands ";
211 }
212};
213
215{
216 EntityAI m_RepackedNewEntity;
217
218 void RepackLambda (EntityAI old_item, string new_item_type, PlayerBase player)
219 {
221 hands.SetHands( player, null );
222 OverrideNewLocation( hands );
223 }
224};
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)
InventoryLocation.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
SoundTypeTent
Definition largetent.c:2