Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
building.c
Go to the documentation of this file.
1typedef Param1<int> DoorStartParams;
3typedef Param1<int> DoorLockParams;
4
5class Building extends EntityAI
6{
7 proto native int GetLaddersCount();
8 proto native vector GetLadderPosTop(int ladderIndex);
9 proto native vector GetLadderPosBottom(int ladderIndex);
10
12 proto native int GetDoorIndex(int componentIndex);
13
15 proto native int GetDoorCount();
16
18 proto native bool IsDoorOpen(int index);
19
21 proto native bool IsDoorOpening(int index);
22
24 proto native bool IsDoorOpeningAjar(int index);
25
27 proto native bool IsDoorClosing(int index);
28
30 proto native bool IsDoorOpened(int index);
31
33 proto native bool IsDoorOpenedAjar(int index);
34
36 proto native bool IsDoorClosed(int index);
37
39 proto native bool IsDoorLocked(int index);
40
42 proto native void PlayDoorSound(int index);
43
45 proto native void OpenDoor(int index);
46
48 proto native void CloseDoor(int index);
49
51 proto native void LockDoor(int index, bool force = false);
52
54 proto native void UnlockDoor(int index, bool animate = true);
55
57 proto native vector GetDoorSoundPos(int index);
58
60 proto native float GetDoorSoundDistance(int index);
61
63 proto native void OutputDoorLog();
64
66 int GetNearestDoorBySoundPos(vector position)
67 {
68 float smallestDist = float.MAX;
69 int nearestDoor = -1;
70
71 int count = GetDoorCount();
72 for (int i = 0; i < count; i++)
73 {
74 float dist = vector.DistanceSq(GetDoorSoundPos(i), position);
75 if (dist < smallestDist)
76 {
77 nearestDoor = i;
78 smallestDist = dist;
79 }
80 }
81
82 return nearestDoor;
83 }
84
87 {
88 }
89
91 void OnDoorOpenFinish(DoorFinishParams params)
92 {
93 }
94
96 void OnDoorOpenAjarStart(DoorStartParams params)
97 {
98 }
99
101 void OnDoorOpenAjarFinish(DoorFinishParams params)
102 {
103 }
104
107 {
108 }
109
111 void OnDoorCloseFinish(DoorFinishParams params)
112 {
113 }
114
116 void OnDoorLocked(DoorLockParams params)
117 {
118 }
119
121 void OnDoorUnlocked(DoorLockParams params)
122 {
123 }
124
125 bool CanDoorBeOpened(int doorIndex, bool checkIfLocked = false)
126 {
127 if (IsDoorOpen(doorIndex))
128 return false;
129
130 if (checkIfLocked)
131 {
132 if (IsDoorLocked(doorIndex))
133 return false;
134 }
135 else
136 {
137 if (!IsDoorLocked(doorIndex))
138 return false;
139 }
140 return true;
141 }
142
143 bool CanDoorBeClosed(int doorIndex)
144 {
145 return IsDoorOpen(doorIndex);
146 }
147
149 bool CanDoorBeLocked(int doorIndex)
150 {
151 return (!IsDoorOpen(doorIndex) && !IsDoorLocked(doorIndex));
152 }
153
162 int GetLockCompatibilityType(int doorIdx)
163 {
164 return 1 << EBuildingLockType.LOCKPICK; //all doors are lockpickable by default
165 }
166
167 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
168 {
169 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_OUTPUT_LOG, "Output Door Log", FadeColors.LIGHT_GREY));
170 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
171
172 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_PLAY_DOOR_SOUND, "Play Door Sound", FadeColors.LIGHT_GREY));
173 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_OPEN_DOOR, "Open Door", FadeColors.LIGHT_GREY));
174 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_CLOSE_DOOR, "Close Door", FadeColors.LIGHT_GREY));
175 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_LOCK_DOOR, "Lock Door", FadeColors.LIGHT_GREY));
176 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_UNLOCK_DOOR, "Unlock Door", FadeColors.LIGHT_GREY));
177 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
178
179 super.GetDebugActions(outputList);
180 }
181
182 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
183 {
184 if (super.OnAction(action_id, player, ctx))
185 return true;
186
187 switch (action_id)
188 {
189 case EActions.BUILDING_PLAY_DOOR_SOUND:
190 PlayDoorSound(GetNearestDoorBySoundPos(player.GetPosition()));
191 return true;
192 }
193
194 if (!GetGame().IsServer())
195 return false;
196
197 switch (action_id)
198 {
199 case EActions.BUILDING_OUTPUT_LOG:
200 OutputDoorLog();
201 return true;
202 case EActions.BUILDING_OPEN_DOOR:
203 OpenDoor(GetNearestDoorBySoundPos(player.GetPosition()));
204 return true;
205 case EActions.BUILDING_CLOSE_DOOR:
206 CloseDoor(GetNearestDoorBySoundPos(player.GetPosition()));
207 return true;
208 case EActions.BUILDING_LOCK_DOOR:
209 LockDoor(GetNearestDoorBySoundPos(player.GetPosition()));
210 return true;
211 case EActions.BUILDING_UNLOCK_DOOR:
212 UnlockDoor(GetNearestDoorBySoundPos(player.GetPosition()));
213 return true;
214 }
215
216 return false;
217 }
218
219 override bool IsBuilding()
220 {
221 return true;
222 }
223
224 override bool CanObstruct()
225 {
226 return true;
227 }
228
229 override bool IsHealthVisible()
230 {
231 return false;
232 }
233
235
236 void Building()
237 {
239 g_Game.ConfigGetIntArray("cfgVehicles " +GetType() + " InteractActions", m_InteractActions);
240 }
241
242 override bool IsInventoryVisible()
243 {
244 return false;
245 }
246
247 override int GetMeleeTargetType()
248 {
249 return EMeleeTargetType.NONALIGNABLE;
250 }
251};
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:97
eBleedingSourceType GetType()
class PASBroadcaster extends AdvancedCommunication IsInventoryVisible
Serialization general interface. Serializer API works with:
Definition serializer.c:56
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override void OnDoorOpenStart(DoorStartParams params)
ContainerLockedBase BuildingSuper GetLockCompatibilityType(int doorIdx)
override void OnDoorLocked(DoorLockParams params)
override void OnDoorUnlocked(DoorLockParams params)
override void OnDoorCloseStart(DoorStartParams params)
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition dayzanimal.c:136
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition dayzanimal.c:125
DayZGame g_Game
Definition dayzgame.c:3868
EActions
Definition eactions.c:2
EBuildingLockType
EMeleeTargetType
proto native CGame GetGame()
array< int > TIntArray
Definition enscript.c:711
const int SAT_DEBUG_ACTION
Definition constants.c:454
ref TIntArray m_InteractActions
Definition itembase.c:4929