Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
building.c
Go to the documentation of this file.
1typedef Param1<int> DoorStartParams;
3typedef Param1<int> DoorLockParams;
4
6{
7
8};
9
11{
12 proto native int GetLaddersCount();
13 proto native vector GetLadderPosTop(int ladderIndex);
14 proto native vector GetLadderPosBottom(int ladderIndex);
15
17 proto native int GetDoorIndex(int componentIndex);
18
20 proto native int GetDoorCount();
21
23 proto native bool IsDoorOpen(int index);
24
26 proto native bool IsDoorOpening(int index);
27
29 proto native bool IsDoorOpeningAjar(int index);
30
32 proto native bool IsDoorClosing(int index);
33
35 proto native bool IsDoorOpened(int index);
36
38 proto native bool IsDoorOpenedAjar(int index);
39
41 proto native bool IsDoorClosed(int index);
42
44 proto native bool IsDoorLocked(int index);
45
47 proto native void PlayDoorSound(int index);
48
50 proto native void OpenDoor(int index);
51
53 proto native void CloseDoor(int index);
54
56 proto native void LockDoor(int index, bool force = false);
57
59 proto native void UnlockDoor(int index, bool animate = true);
60
62 proto native vector GetDoorSoundPos(int index);
63
65 proto native float GetDoorSoundDistance(int index);
66
68 proto native void OutputDoorLog();
69
72 {
73 float smallestDist = float.MAX;
74 int nearestDoor = -1;
75
76 int count = GetDoorCount();
77 for (int i = 0; i < count; i++)
78 {
79 float dist = vector.DistanceSq(GetDoorSoundPos(i), position);
80 if (dist < smallestDist)
81 {
82 nearestDoor = i;
83 smallestDist = dist;
84 }
85 }
86
87 return nearestDoor;
88 }
89
92 {
93 }
94
97 {
98 }
99
102 {
103 }
104
107 {
108 }
109
112 {
113 }
114
117 {
118 }
119
122 {
123 }
124
127 {
128 }
129
130 bool CanDoorBeOpened(int doorIndex, bool checkIfLocked = false)
131 {
132 if (IsDoorOpen(doorIndex))
133 return false;
134
135 if (checkIfLocked)
136 {
137 if (IsDoorLocked(doorIndex))
138 return false;
139 }
140 else
141 {
142 if (!IsDoorLocked(doorIndex))
143 return false;
144 }
145 return true;
146 }
147
148 bool CanDoorBeClosed(int doorIndex)
149 {
150 return IsDoorOpen(doorIndex);
151 }
152
154 bool CanDoorBeLocked(int doorIndex)
155 {
156 return (!IsDoorOpen(doorIndex) && !IsDoorLocked(doorIndex));
157 }
158
168 {
169 return 1 << EBuildingLockType.LOCKPICK; //all doors are lockpickable by default
170 }
171
172 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
173 {
174 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_OUTPUT_LOG, "Output Door Log", FadeColors.LIGHT_GREY));
175 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
176
177 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_PLAY_DOOR_SOUND, "Play Door Sound", FadeColors.LIGHT_GREY));
178 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_OPEN_DOOR, "Open Door", FadeColors.LIGHT_GREY));
179 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_CLOSE_DOOR, "Close Door", FadeColors.LIGHT_GREY));
180 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_LOCK_DOOR, "Lock Door", FadeColors.LIGHT_GREY));
181 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_UNLOCK_DOOR, "Unlock Door", FadeColors.LIGHT_GREY));
182 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
183
184 if (Gizmo_IsSupported())
185 {
186 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
187 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
188 }
189
190 super.GetDebugActions(outputList);
191 }
192
193 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
194 {
195 if (super.OnAction(action_id, player, ctx))
196 return true;
197
198 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
199 {
200 switch (action_id)
201 {
202 case EActions.GIZMO_OBJECT:
203 if (GetGizmoApi())
205 return true;
206 }
207 }
208
209 switch (action_id)
210 {
211 case EActions.BUILDING_PLAY_DOOR_SOUND:
212 PlayDoorSound(GetNearestDoorBySoundPos(player.GetPosition()));
213 return true;
214 }
215
216 if (!g_Game.IsServer())
217 return false;
218
219 switch (action_id)
220 {
221 case EActions.BUILDING_OUTPUT_LOG:
223 return true;
224 case EActions.BUILDING_OPEN_DOOR:
225 OpenDoor(GetNearestDoorBySoundPos(player.GetPosition()));
226 return true;
227 case EActions.BUILDING_CLOSE_DOOR:
228 CloseDoor(GetNearestDoorBySoundPos(player.GetPosition()));
229 return true;
230 case EActions.BUILDING_LOCK_DOOR:
231 LockDoor(GetNearestDoorBySoundPos(player.GetPosition()));
232 return true;
233 case EActions.BUILDING_UNLOCK_DOOR:
234 UnlockDoor(GetNearestDoorBySoundPos(player.GetPosition()));
235 return true;
236 }
237
238 return false;
239 }
240
241 override bool IsBuilding()
242 {
243 return true;
244 }
245
246 override bool CanObstruct()
247 {
248 return true;
249 }
250
251 override bool IsHealthVisible()
252 {
253 return false;
254 }
255
257
258 void Building()
259 {
261 g_Game.ConfigGetIntArray("cfgVehicles " +GetType() + " InteractActions", m_InteractActions);
262 }
263
264 override bool IsInventoryVisible()
265 {
266 return false;
267 }
268
269 override int GetMeleeTargetType()
270 {
271 return EMeleeTargetType.NONALIGNABLE;
272 }
273};
274
275//-----------------------------------------------------------------------------
277{
278};
279
280//-----------------------------------------------------------------------------
281/*
282class WindSock : Entity
283{
284};
285*/
Param1< int > DoorStartParams
Definition building.c:1
Param2< int, bool > DoorFinishParams
Definition building.c:2
Param1< int > DoorLockParams
Definition building.c:3
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition entityai.c:104
eBleedingSourceType GetType()
override bool IsInventoryVisible()
Definition building.c:264
override bool IsBuilding()
Definition building.c:241
proto native int GetDoorIndex(int componentIndex)
Gets the index of the door based on the view geometry component index.
proto native bool IsDoorLocked(int index)
When the door is locked.
ref TIntArray m_InteractActions
Definition building.c:256
proto native void LockDoor(int index, bool force=false)
Locks the door if not already locked, resets the door health. 'force = true' will close the door if o...
proto native bool IsDoorClosed(int index)
When the phase is at the close phase target (0.0).
proto native int GetDoorCount()
Returns the number of the doors in the building.
proto native bool IsDoorOpenedAjar(int index)
When the phase is at the ajar phase target (0.2).
proto native bool IsDoorOpened(int index)
When the phase is at the open phase target (1.0).
proto native bool IsDoorOpening(int index)
When the wanted phase is at the open phase target (1.0).
proto native vector GetDoorSoundPos(int index)
Position in world space for where the door sounds are played from.
void OnDoorOpenStart(DoorStartParams params)
Event for when the door starts opening.
Definition building.c:91
void OnDoorLocked(DoorLockParams params)
Event for when the door is locked.
Definition building.c:121
proto native void PlayDoorSound(int index)
Plays the appropriate sound at the door, based on animation phase and state.
proto native vector GetLadderPosBottom(int ladderIndex)
int GetLockCompatibilityType(int doorIdx)
Which door is compatible with which key (door idx supplied).
Definition building.c:167
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition building.c:193
void OnDoorCloseFinish(DoorFinishParams params)
Event for when the door finishes closing.
Definition building.c:116
void OnDoorCloseStart(DoorStartParams params)
Event for when the door starts closing.
Definition building.c:111
void OnDoorUnlocked(DoorLockParams params)
Event for when the door is unlocked.
Definition building.c:126
override int GetMeleeTargetType()
Definition building.c:269
proto native void OpenDoor(int index)
Attempts to open the door.
override bool CanObstruct()
Definition building.c:246
void OnDoorOpenFinish(DoorFinishParams params)
Event for when the door finishes opening.
Definition building.c:96
override bool IsHealthVisible()
Definition building.c:251
proto native bool IsDoorClosing(int index)
When the wanted phase is at the close phase target (0.0).
proto native bool IsDoorOpeningAjar(int index)
When the wanted phase is at the ajar phase target (0.2).
void OnDoorOpenAjarFinish(DoorFinishParams params)
Event for when the door finishes opening ajarred (usually after unlock).
Definition building.c:106
proto native bool IsDoorOpen(int index)
When the door is requested to be fully open (animation wanted phase is greater than 0....
proto native vector GetLadderPosTop(int ladderIndex)
bool CanDoorBeLocked(int doorIndex)
Check if the door is closed and if the door is unlocked.
Definition building.c:154
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition building.c:172
void Building()
Definition building.c:258
proto native void UnlockDoor(int index, bool animate=true)
Unlocks the door if locked, AJAR animation optional.
bool CanDoorBeOpened(int doorIndex, bool checkIfLocked=false)
Definition building.c:130
bool CanDoorBeClosed(int doorIndex)
Definition building.c:148
proto native float GetDoorSoundDistance(int index)
Audible distance for the door sound.
int GetNearestDoorBySoundPos(vector position)
Gets the nearest door based on the sound position (quick and dirty function for debugging).
Definition building.c:71
void OnDoorOpenAjarStart(DoorStartParams params)
Event for when the door starts opening ajarred (usually after unlock).
Definition building.c:101
proto native void OutputDoorLog()
Requires special build as logging is disabled even on internal builds due to memory usage....
proto native void CloseDoor(int index)
Attempts to close the door.
proto native int GetLaddersCount()
void Man()
Definition man.c:43
void EntityAIType()
Definition entityaitype.c:3
void EntityType()
Definition entitytype.c:3
proto void SelectObject(Object object)
Sets the transform of the object directly.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
DayZGame g_Game
Definition dayzgame.c:3942
EActions
Definition eactions.c:2
EBuildingLockType
EMeleeTargetType
Serializer ParamsReadContext
Definition gameplay.c:15
proto GizmoApi GetGizmoApi()
array< int > TIntArray
Definition enscript.c:714
const int SAT_DEBUG_ACTION
Definition constants.c:457