DayZ 1.24
Loading...
Searching...
No Matches
Building.c
Go to the documentation of this file.
4
5class Building extends EntityAI
6{
10
13
16
19
22
25
28
31
34
37
40
43
46
49
51 proto native void LockDoor(int index, bool force = false);
52
55
58
61
64
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;
79 }
80 }
81
82 return nearestDoor;
83 }
84
89
94
99
104
109
114
119
124
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
144 {
145 return IsDoorOpen(doorIndex);
146 }
147
150 {
151 return (!IsDoorOpen(doorIndex) && !IsDoorLocked(doorIndex));
152 }
153
155 {
156 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_OUTPUT_LOG, "Output Door Log", FadeColors.LIGHT_GREY));
157 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, " --- ", FadeColors.LIGHT_GREY));
158
159 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_PLAY_DOOR_SOUND, "Play Door Sound", FadeColors.LIGHT_GREY));
160 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_OPEN_DOOR, "Open Door", FadeColors.LIGHT_GREY));
161 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_CLOSE_DOOR, "Close Door", FadeColors.LIGHT_GREY));
162 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_LOCK_DOOR, "Lock Door", FadeColors.LIGHT_GREY));
163 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_UNLOCK_DOOR, "Unlock Door", FadeColors.LIGHT_GREY));
164 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, " --- ", FadeColors.LIGHT_GREY));
165
166 super.GetDebugActions(outputList);
167 }
168
170 {
171 if (super.OnAction(action_id, player, ctx))
172 return true;
173
174 switch (action_id)
175 {
176 case EActions.BUILDING_PLAY_DOOR_SOUND:
177 PlayDoorSound(GetNearestDoorBySoundPos(player.GetPosition()));
178 return true;
179 }
180
181 if (!GetGame().IsServer())
182 return false;
183
184 switch (action_id)
185 {
186 case EActions.BUILDING_OUTPUT_LOG:
187 OutputDoorLog();
188 return true;
189 case EActions.BUILDING_OPEN_DOOR:
190 OpenDoor(GetNearestDoorBySoundPos(player.GetPosition()));
191 return true;
192 case EActions.BUILDING_CLOSE_DOOR:
193 CloseDoor(GetNearestDoorBySoundPos(player.GetPosition()));
194 return true;
195 case EActions.BUILDING_LOCK_DOOR:
196 LockDoor(GetNearestDoorBySoundPos(player.GetPosition()));
197 return true;
198 case EActions.BUILDING_UNLOCK_DOOR:
199 UnlockDoor(GetNearestDoorBySoundPos(player.GetPosition()));
200 return true;
201 }
202
203 return false;
204 }
205
206 override bool IsBuilding()
207 {
208 return true;
209 }
210
211 override bool CanObstruct()
212 {
213 return true;
214 }
215
216 override bool IsHealthVisible()
217 {
218 return false;
219 }
220
222
223 void Building()
224 {
226 g_Game.ConfigGetIntArray("cfgVehicles " + GetType() + " InteractActions", m_InteractActions);
227 }
228
229 override bool IsInventoryVisible()
230 {
231 return false;
232 }
233
234 override int GetMeleeTargetType()
235 {
236 return EMeleeTargetType.NONALIGNABLE;
237 }
238};
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()
DayZGame g_Game
Definition DayZGame.c:3528
EActions
Definition EActions.c:2
EMeleeTargetType
ref TIntArray m_InteractActions
Definition ItemBase.c:4764
ref TIntArray m_InteractActions
Definition Building.c:221
proto native bool IsDoorClosed(int index)
When the phase is at the close phase target (0.0)
proto native vector GetLadderPosBottom(int ladderIndex)
override bool IsHealthVisible()
Definition Building.c:216
proto native bool IsDoorClosing(int index)
When the wanted phase is at the close phase target (0.0)
void Building()
Definition Building.c:223
proto native int GetLaddersCount()
override bool CanObstruct()
Definition Building.c:211
void OnDoorCloseFinish(DoorFinishParams params)
Event for when the door finishes closing.
Definition Building.c:111
proto native void CloseDoor(int index)
Attempts to close the door.
proto native bool IsDoorOpening(int index)
When the wanted phase is at the open phase target (1.0)
int GetNearestDoorBySoundPos(vector position)
Gets the nearest door based on the sound position (quick and dirty function for debugging)
Definition Building.c:66
proto native bool IsDoorOpened(int index)
When the phase is at the open phase target (1.0)
proto native void UnlockDoor(int index)
Unlocks the door if locked.
void OnDoorCloseStart(DoorStartParams params)
Event for when the door starts closing.
Definition Building.c:106
proto native bool IsDoorLocked(int index)
When the door is locked.
override int GetMeleeTargetType()
Definition Building.c:234
proto native bool IsDoorOpeningAjar(int index)
When the wanted phase is at the ajar phase target (0.2)
proto native void OpenDoor(int index)
Attempts to open the door.
override bool IsBuilding()
Definition Building.c:206
void OnDoorOpenAjarStart(DoorStartParams params)
Event for when the door starts opening ajarred (usually after unlock)
Definition Building.c:96
void OnDoorLocked(DoorLockParams params)
Event for when the door is locked.
Definition Building.c:116
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 void OutputDoorLog()
Requires special build as logging is disabled even on internal builds due to memory usage....
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition Building.c:169
proto native int GetDoorCount()
Returns the number of the doors in the building.
proto native void PlayDoorSound(int index)
Plays the appropriate sound at the door, based on animation phase and state.
void OnDoorOpenStart(DoorStartParams params)
Event for when the door starts opening.
Definition Building.c:86
proto native vector GetLadderPosTop(int ladderIndex)
void OnDoorOpenAjarFinish(DoorFinishParams params)
Event for when the door finishes opening ajarred (usually after unlock)
Definition Building.c:101
bool CanDoorBeOpened(int doorIndex, bool checkIfLocked=false)
Definition Building.c:125
proto native float GetDoorSoundDistance(int index)
Audible distance for the door sound.
proto native bool IsDoorOpenedAjar(int index)
When the phase is at the ajar phase target (0.2)
bool CanDoorBeLocked(int doorIndex)
Check if the door is closed and if the door is unlocked.
Definition Building.c:149
proto native bool IsDoorOpen(int index)
When the door is requested to be fully open (animation wanted phase is greater than 0....
override bool IsInventoryVisible()
Definition Building.c:229
bool CanDoorBeClosed(int doorIndex)
Definition Building.c:143
void OnDoorUnlocked(DoorLockParams params)
Event for when the door is unlocked.
Definition Building.c:121
proto native vector GetDoorSoundPos(int index)
Position in world space for where the door sounds are played from.
proto native int GetDoorIndex(int componentIndex)
Gets the index of the door based on the view geometry component index.
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition Building.c:154
void OnDoorOpenFinish(DoorFinishParams params)
Event for when the door finishes opening.
Definition Building.c:91
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
proto native CGame GetGame()
array< int > TIntArray
Definition EnScript.c:668
const int SAT_DEBUG_ACTION
Definition constants.c:424