DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
OvenIndoor.c
Go to the documentation of this file.
1class OvenIndoor extends FireplaceBase
2{
3 protected float m_SmokePosX;
4 protected float m_SmokePosY;
5 protected float m_SmokePosZ;
6 protected int m_FirePointIndex = 1; //limited to 1 decimal place (1-9)
7
8 static const string OVENPOINT_ACTION_SELECTION = "oven_action";
9 static const string OVENPOINT_FIRE_POSITION = "oven_point";
10 static const string OVENPOINT_PLACE_ROT = "oven_rot";
11 static const string OVENPOINT_SMOKE_POSITION = "oven_smoke";
12
14 {
15 //Particles - default for FireplaceBase
23
24 //register sync variables
25 RegisterNetSyncVariableFloat( "m_SmokePosX", 0, 0, 2 );
26 RegisterNetSyncVariableFloat( "m_SmokePosY", 0, 0, 2 );
27 RegisterNetSyncVariableFloat( "m_SmokePosZ", 0, 0, 2 );
28 RegisterNetSyncVariableInt( "m_FirePointIndex", 0, 9 );
29
30 m_LightDistance = 50;
31 m_RoofAbove = true;
32 }
33
34 //================================================================
35 // ONSTORESAVE/LOAD/AFTERLOAD
36 //================================================================
37 override void OnStoreSave( ParamsWriteContext ctx )
38 {
39 super.OnStoreSave( ctx );
40
41 //fire point name
43
44 //smoke position
45 ctx.Write( m_SmokePosX );
46 ctx.Write( m_SmokePosY );
47 ctx.Write( m_SmokePosZ );
48 }
49
50 override bool OnStoreLoad( ParamsReadContext ctx, int version )
51 {
52 if ( !super.OnStoreLoad( ctx, version ) )
53 return false;
54
55 //--- Fireplace Indoor data ---
56 //fire point name
57 if ( !ctx.Read( m_FirePointIndex ) )
58 {
59 m_FirePointIndex = 1; //set default
60 return false;
61 }
62
63 //smoke position
64 if ( !ctx.Read( m_SmokePosX ) )
65 {
66 m_SmokePosX = 0; //set default
67 return false;
68 }
69 if ( !ctx.Read( m_SmokePosY ) )
70 {
71 m_SmokePosY = 0; //set default
72 return false;
73 }
74 if ( !ctx.Read( m_SmokePosZ ) )
75 {
76 m_SmokePosZ = 0; //set default
77 return false;
78 }
79 //---
80
81 return true;
82 }
83
84 //================================================================
85 // FIRE POINT (HOUSE)
86 // LIMITED TO 1 DECIMAL PLACE (0-9)
87 //================================================================
88 static int GetFirePointIndex( string action_selection )
89 {
90 int index_location = action_selection.Length() - 1;
91 return action_selection.Substring( index_location, 1 ).ToInt();
92 }
93
94 void SetFirePointIndex( int fire_point_index )
95 {
96 m_FirePointIndex = fire_point_index;
97 }
98
99 static bool CanPlaceFireplaceInSelectedSpot( Object building, int fire_point_index, out vector fire_point_pos_world, out vector fire_point_rot_world )
100 {
101 //Get fire point index position
102 vector fire_point_pos = building.GetSelectionPositionMS( OVENPOINT_FIRE_POSITION + fire_point_index.ToString() );
103 vector fire_point_rot = building.GetSelectionPositionMS( OVENPOINT_PLACE_ROT + fire_point_index.ToString() );
104 fire_point_pos_world = building.ModelToWorld( fire_point_pos );
105 fire_point_rot_world = building.ModelToWorld( fire_point_rot );
106
107 //check if there is any FireplaceIndoor objects near selected fire point
108 ref array<Object> nearest_objects = new array<Object>;
109 ref array<CargoBase> proxy_cargos = new array<CargoBase>;
110 GetGame().GetObjectsAtPosition3D( fire_point_pos_world, 1, nearest_objects, proxy_cargos );
111
112 for ( int i = 0; i < nearest_objects.Count(); ++i )
113 {
114 Object object = nearest_objects.Get( i );
115
116 if ( object.IsInherited( OvenIndoor ) )
117 {
118 return false;
119 }
120 }
121
122 return true;
123 }
124
125 void SetSmokePointPosition( vector smoke_point_pos )
126 {
127 m_SmokePosX = smoke_point_pos[0];
128 m_SmokePosY = smoke_point_pos[1];
129 m_SmokePosZ = smoke_point_pos[2];
130 }
131
132 //================================================================
133 // PARTICLES
134 //================================================================
135 override protected vector GetSmokeEffectPosition()
136 {
137 return Vector( m_SmokePosX, m_SmokePosY, m_SmokePosZ );
138 }
139
140 //small smoke
142 {
144 }
145
146 //normal smoke
148 {
150 }
151
152 //================================================================
153 // STATE
154 //================================================================
155 override bool IsIndoorOven()
156 {
157 return true;
158 }
159
160 override bool CanReleaseAttachment(EntityAI attachment)
161 {
162 if (!super.CanReleaseAttachment(attachment))
163 {
164 return false;
165 }
166
167 ItemBase item = ItemBase.Cast(attachment);
168 if (IsKindling(item) || IsFuel(item))
169 {
170 return !IsBurning();
171 }
172
173 return true;
174 }
175
176 override void EEItemAttached(EntityAI item, string slot_name)
177 {
178 super.EEItemAttached(item, slot_name);
179
180 ItemBase item_base = ItemBase.Cast(item);
181
182 if (IsKindling(item_base) || IsFuel(item_base))
183 {
184 AddToFireConsumables(item_base);
185 }
186
187 // direct cooking/smoking slots
188 bool edible_base_attached = false;
189 switch (slot_name)
190 {
191 case "DirectCookingA":
192 m_DirectCookingSlots[0] = item_base;
193 edible_base_attached = true;
194 break;
195 case "SmokingA":
196 m_SmokingSlots[0] = item_base;
197 edible_base_attached = true;
198 break;
199 case "SmokingB":
200 m_SmokingSlots[1] = item_base;
201 edible_base_attached = true;
202 break;
203 }
204
205 // reset cooking time (to prevent the cooking exploit)
206 if (GetGame().IsServer() && edible_base_attached)
207 {
208 Edible_Base edBase = Edible_Base.Cast(item_base);
209 if (edBase)
210 {
211 if ( edBase.GetFoodStage())
212 {
213 edBase.SetCookingTime(0);
214 }
215 }
216 }
217
219 }
220
221 override void EEItemDetached(EntityAI item, string slot_name)
222 {
223 super.EEItemDetached(item, slot_name);
224
225 ItemBase item_base = ItemBase.Cast(item);
226
227 if (IsKindling(item_base) || IsFuel(item_base))
228 {
230 }
231
232 CheckForDestroy();
233
234 // direct cooking/smoking slots
235 switch (slot_name)
236 {
237 case "DirectCookingA":
238 m_DirectCookingSlots[0] = null;
239 break;
240 case "SmokingA":
241 m_SmokingSlots[0] = null;
242 break;
243
244 case "SmokingB":
245 m_SmokingSlots[1] = null;
246 break;
247 }
248
249 // cookware-specifics (remove audio visuals)
250 if (item_base.Type() == ATTACHMENT_COOKING_POT)
251 {
252 ClearCookingEquipment(item_base);
253 Bottle_Base cooking_pot = Bottle_Base.Cast(item);
254 cooking_pot.RemoveAudioVisualsOnClient();
255 }
256 if (item_base.Type() == ATTACHMENT_CAULDRON)
257 {
258 ClearCookingEquipment(item_base);
259 Bottle_Base cauldron = Bottle_Base.Cast(item);
260 cauldron.RemoveAudioVisualsOnClient();
261 }
262 if (item_base.Type() == ATTACHMENT_FRYING_PAN)
263 {
264 ClearCookingEquipment(item_base);
265 FryingPan frying_pan = FryingPan.Cast(item);
266 frying_pan.RemoveAudioVisualsOnClient();
267 }
268
270 }
271
272 //================================================================
273 // CONDITIONS
274 //================================================================
275 //this into/outo parent.Cargo
276 override bool CanPutInCargo( EntityAI parent )
277 {
278 return false;
279 }
280
281 override bool CanRemoveFromCargo( EntityAI parent )
282 {
283 return true;
284 }
285
286 //hands
287 override bool CanPutIntoHands( EntityAI parent )
288 {
289 return false;
290 }
291
292 override bool CanRemoveFromHands( EntityAI player )
293 {
294 return false;
295 }
296
297 // Item-to-item fire distribution
298 override bool HasFlammableMaterial()
299 {
300 return true;
301 }
302
303 override bool CanBeIgnitedBy( EntityAI igniter = NULL )
304 {
305 if ( HasAnyKindling() && !GetHierarchyParent() )
306 {
307 return true;
308 }
309
310 return false;
311 }
312
313 override bool CanIgniteItem( EntityAI ignite_target = NULL )
314 {
315 if ( IsBurning() )
316 {
317 return true;
318 }
319
320 return false;
321 }
322
323 override bool IsIgnited()
324 {
325 return IsBurning();
326 }
327
328 override void OnIgnitedTarget( EntityAI ignited_item )
329 {
330 }
331
332 override void OnIgnitedThis( EntityAI fire_source )
333 {
334 //start fire
335 StartFire();
336 }
337
338 override bool IsThisIgnitionSuccessful( EntityAI item_source = NULL )
339 {
340 //check kindling
341 if ( !HasAnyKindling() )
342 {
343 return false;
344 }
345
346 //check wetness
347 if ( IsWet() )
348 {
349 return false;
350 }
351
352 return true;
353 }
354}
ActionPlaceFireplaceIndoor m_FirePointIndex
void RefreshFireplaceVisuals()
bool HasAnyKindling()
ATTACHMENT_FRYING_PAN
ATTACHMENT_CAULDRON
protected int PARTICLE_SMALL_FIRE
protected ItemBase m_SmokingSlots[SMOKING_SLOT_COUNT]
protected void RemoveFromFireConsumables(FireConsumable fire_consumable)
protected bool IsFuel(ItemBase item)
Returns if item attached to fireplace is fuel.
protected int PARTICLE_FIRE_END
protected int PARTICLE_SMALL_SMOKE
protected FireConsumable GetFireConsumableByItem(ItemBase item)
protected int PARTICLE_FIRE_START
protected int PARTICLE_NORMAL_FIRE
protected bool m_RoofAbove
protected void AddToFireConsumables(ItemBase item)
ATTACHMENT_COOKING_POT
protected int PARTICLE_STEAM_END
bool IsBurning()
bool IsWet()
void StartFire(bool force_start=false)
protected float m_LightDistance
protected bool IsKindling(ItemBase item)
Returns if item attached to fireplace is kindling.
protected Particle m_ParticleSmallSmoke
protected int PARTICLE_NORMAL_SMOKE
protected Particle m_ParticleNormalSmoke
void ClearCookingEquipment()
DEPRECATED.
protected ItemBase m_DirectCookingSlots[DIRECT_COOKING_SLOT_COUNT]
void PlayParticle(int particle_id=-1)
Method to tell the particle to start playing.
proto native void GetObjectsAtPosition3D(vector pos, float radius, out array< Object > objects, out array< CargoBase > proxyCargos)
Returns list of all objects in sphere "radius" around position "pos".
override bool CanRemoveFromHands(EntityAI player)
Definition OvenIndoor.c:292
void SetSmokePointPosition(vector smoke_point_pos)
Definition OvenIndoor.c:125
override void OnIgnitedTarget(EntityAI ignited_item)
Definition OvenIndoor.c:328
override protected vector GetSmokeEffectPosition()
Definition OvenIndoor.c:135
void OvenIndoor()
Definition OvenIndoor.c:13
override void OnStoreSave(ParamsWriteContext ctx)
Definition OvenIndoor.c:37
static int GetFirePointIndex(string action_selection)
Definition OvenIndoor.c:88
protected float m_SmokePosZ
override bool CanBeIgnitedBy(EntityAI igniter=NULL)
Definition OvenIndoor.c:303
override bool CanPutInCargo(EntityAI parent)
Definition OvenIndoor.c:276
protected float m_SmokePosY
override bool IsIgnited()
Definition OvenIndoor.c:323
override void ParticleNormalSmokeStart()
Definition OvenIndoor.c:147
override bool CanReleaseAttachment(EntityAI attachment)
Definition OvenIndoor.c:160
void SetFirePointIndex(int fire_point_index)
Definition OvenIndoor.c:94
override void EEItemDetached(EntityAI item, string slot_name)
Definition OvenIndoor.c:221
override void OnIgnitedThis(EntityAI fire_source)
Definition OvenIndoor.c:332
override bool CanIgniteItem(EntityAI ignite_target=NULL)
Definition OvenIndoor.c:313
override bool IsThisIgnitionSuccessful(EntityAI item_source=NULL)
Definition OvenIndoor.c:338
override bool CanPutIntoHands(EntityAI parent)
Definition OvenIndoor.c:287
override bool CanRemoveFromCargo(EntityAI parent)
Definition OvenIndoor.c:281
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition OvenIndoor.c:50
override bool HasFlammableMaterial()
Definition OvenIndoor.c:298
override void EEItemAttached(EntityAI item, string slot_name)
Definition OvenIndoor.c:176
static bool CanPlaceFireplaceInSelectedSpot(Object building, int fire_point_index, out vector fire_point_pos_world, out vector fire_point_rot_world)
Definition OvenIndoor.c:99
override bool IsIndoorOven()
Definition OvenIndoor.c:155
override void ParticleSmallSmokeStart()
Definition OvenIndoor.c:141
protected float m_SmokePosX
static const int HOUSE_NORMAL_SMOKE
static const int HOUSE_SMALL_SMOKE
static const int OVEN_NORMAL_FIRE
static const int OVEN_SMALL_FIRE
static const int OVEN_FIRE_START
static const int OVEN_FIRE_END
static const int BARREL_FIRE_STEAM_2END
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
proto native int ToInt()
Converts string to integer.
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.
proto native int Length()
Returns length of string.