DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
FireplaceIndoor.c
Go to the documentation of this file.
1class FireplaceIndoor 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 FIREPOINT_ACTION_SELECTION = "fireplace_action";
9 static const string FIREPOINT_FIRE_POSITION = "fireplace_point";
10 static const string FIREPOINT_PLACE_ROT = "fireplace_rot";
11 static const string FIREPOINT_SMOKE_POSITION = "fireplace_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( FIREPOINT_FIRE_POSITION + fire_point_index.ToString() );
103 vector fire_point_rot = building.GetSelectionPositionMS( FIREPOINT_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, 0.25, 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( FireplaceIndoor ) )
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 IsFireplaceIndoor()
156 {
157 return true;
158 }
159
160 override void EEItemAttached(EntityAI item, string slot_name)
161 {
162 super.EEItemAttached(item, slot_name);
163
164 ItemBase item_base = ItemBase.Cast(item);
165 if ( IsKindling(item_base) || IsFuel(item_base))
166 {
167 AddToFireConsumables(item_base);
168 }
169
170 // direct cooking slots, smoking slots
171 bool edible_base_attached = false;
172 switch ( slot_name )
173 {
174 case "DirectCookingA":
175 m_DirectCookingSlots[0] = item_base;
176 edible_base_attached = true;
177 break;
178 case "DirectCookingB":
179 m_DirectCookingSlots[1] = item_base;
180 edible_base_attached = true;
181 break;
182 case "DirectCookingC":
183 m_DirectCookingSlots[2] = item_base;
184 edible_base_attached = true;
185 break;
186
187 case "SmokingA":
188 m_SmokingSlots[0] = item_base;
189 edible_base_attached = true;
190 break;
191 case "SmokingB":
192 m_SmokingSlots[1] = item_base;
193 edible_base_attached = true;
194 break;
195 case "SmokingC":
196 m_SmokingSlots[2] = item_base;
197 edible_base_attached = true;
198 break;
199 case "SmokingD":
200 m_SmokingSlots[3] = 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 "DirectCookingB":
241 m_DirectCookingSlots[1] = null;
242 break;
243 case "DirectCookingC":
244 m_DirectCookingSlots[2] = null;
245 break;
246
247 case "SmokingA":
248 m_SmokingSlots[0] = null;
249 break;
250 case "SmokingB":
251 m_SmokingSlots[1] = null;
252 break;
253 case "SmokingC":
254 m_SmokingSlots[2] = null;
255 break;
256 case "SmokingD":
257 m_SmokingSlots[3] = null;
258 break;
259 }
260
261 // cookware-specifics (remove audio visuals)
262 if (item_base.Type() == ATTACHMENT_COOKING_POT)
263 {
264 ClearCookingEquipment(item_base);
265 Bottle_Base cooking_pot = Bottle_Base.Cast(item);
266 cooking_pot.RemoveAudioVisualsOnClient();
267 }
268 if (item_base.Type() == ATTACHMENT_CAULDRON)
269 {
270 ClearCookingEquipment(item_base);
271 Bottle_Base cauldron = Bottle_Base.Cast(item);
272 cauldron.RemoveAudioVisualsOnClient();
273 }
274 if (item_base.Type() == ATTACHMENT_FRYING_PAN)
275 {
276 ClearCookingEquipment(item_base);
277 FryingPan frying_pan = FryingPan.Cast(item);
278 frying_pan.RemoveAudioVisualsOnClient();
279 }
280
282 }
283
284 //================================================================
285 // CONDITIONS
286 //================================================================
287 //this into/outo parent.Cargo
288 override bool CanPutInCargo( EntityAI parent )
289 {
290 return false;
291 }
292
293 override bool CanRemoveFromCargo( EntityAI parent )
294 {
295 return true;
296 }
297
298 //cargo item into/outo this.Cargo
299 override bool CanReceiveItemIntoCargo( EntityAI item )
300 {
301 return super.CanReceiveItemIntoCargo( item );
302 }
303
304 //hands
305 override bool CanPutIntoHands( EntityAI parent )
306 {
307 return false;
308 }
309
310 override bool CanRemoveFromHands( EntityAI player )
311 {
312 return false;
313 }
314
315 // Item-to-item fire distribution
316 override bool HasFlammableMaterial()
317 {
318 return true;
319 }
320
321 override bool CanBeIgnitedBy( EntityAI igniter = NULL )
322 {
323 if ( HasAnyKindling() && !GetHierarchyParent() )
324 {
325 return true;
326 }
327
328 return false;
329 }
330
331 override bool CanIgniteItem( EntityAI ignite_target = NULL )
332 {
333 if ( IsBurning() )
334 {
335 return true;
336 }
337
338 return false;
339 }
340
341 override bool IsIgnited()
342 {
343 return IsBurning();
344 }
345
346 override void OnIgnitedTarget( EntityAI ignited_item )
347 {
348 }
349
350 override void OnIgnitedThis( EntityAI fire_source )
351 {
352 //start fire
353 StartFire();
354 }
355
356 override bool IsThisIgnitionSuccessful( EntityAI item_source = NULL )
357 {
358 SetIgniteFailure( false );
359 Param1<bool> failure;
360
361 //check kindling
362 if ( !HasAnyKindling() )
363 {
364 return false;
365 }
366
367 //check wetness
368 if ( IsWet() )
369 {
370 SetIgniteFailure( true );
371
372 failure = new Param1<bool>( GetIgniteFailure() );
373 GetGame().RPCSingleParam( this, FirePlaceFailure.WET, failure, true );
374 return false;
375 }
376
377 return true;
378 }
379}
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
bool GetIgniteFailure()
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)
void SetIgniteFailure(bool failure)
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.
void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient=null)
see CGame.RPC
Definition Game.c:882
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)
void SetSmokePointPosition(vector smoke_point_pos)
override void OnIgnitedTarget(EntityAI ignited_item)
override protected vector GetSmokeEffectPosition()
override void OnStoreSave(ParamsWriteContext ctx)
static int GetFirePointIndex(string action_selection)
override bool CanReceiveItemIntoCargo(EntityAI item)
protected float m_SmokePosZ
override bool CanBeIgnitedBy(EntityAI igniter=NULL)
override bool CanPutInCargo(EntityAI parent)
protected float m_SmokePosY
override bool IsIgnited()
override void ParticleNormalSmokeStart()
void SetFirePointIndex(int fire_point_index)
override void EEItemDetached(EntityAI item, string slot_name)
override void OnIgnitedThis(EntityAI fire_source)
override bool CanIgniteItem(EntityAI ignite_target=NULL)
override bool IsThisIgnitionSuccessful(EntityAI item_source=NULL)
override bool CanPutIntoHands(EntityAI parent)
override bool CanRemoveFromCargo(EntityAI parent)
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override bool HasFlammableMaterial()
override void EEItemAttached(EntityAI item, string slot_name)
static bool CanPlaceFireplaceInSelectedSpot(Object building, int fire_point_index, out vector fire_point_pos_world, out vector fire_point_rot_world)
override void ParticleSmallSmokeStart()
override bool IsFireplaceIndoor()
protected float m_SmokePosX
static const int HOUSE_NORMAL_SMOKE
static const int HOUSE_SMALL_SMOKE
static const int HOUSE_FIRE_END
static const int HOUSE_NORMAL_FIRE
static const int HOUSE_FIRE_START
static const int HOUSE_FIRE_STEAM_2END
static const int HOUSE_SMALL_FIRE
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.