DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Environment.c
См. документацию.
1
9
10class EnvironmentSnapshotData
11{
14}
15
21
26class Environment
27{
28 const float RAIN_LIMIT_LOW = 0.05;
29
30 protected const float SNOWFALL_LIMIT_LOW = 0.5;
31 protected const float SNOWFALL_WIND_COMBINED_THRESHOLD = 1.3;
32
33 const float WATER_LEVEL_HIGH = 1.5;
34 const float WATER_LEVEL_MID = 1.2;
35 const float WATER_LEVEL_LOW = 0.5;
36 const float WATER_LEVEL_NONE = 0.15;
37
38 protected float m_WetDryTick; //ticks passed since last clothing wetting or drying
39 protected float m_ItemsWetnessMax;
40 protected float m_RoofCheckTimer; // keeps info about tick time
41
42 //player
44 protected float m_PlayerHeightPos; // y position of player above water level (meters)
45 protected float m_PlayerSpeed; // 1-3 speed of player movement
46 protected float m_PlayerTemperature; //34-44
47 protected float m_PlayerHeat; //3-9 heatcomfort generated by entites movement
48 protected float m_HeatComfort;
49 protected float m_TargetHeatComfort;
50
51 //environment
52 protected float m_Rain = 0; // 0-1 amount of rain
53 protected float m_Snowfall = 0; // 0-1 amount of rain
54 protected float m_Wind = 0; // strength of wind
55 protected float m_Fog = 0; // 0-1 how foggy it is
56 protected float m_DayOrNight = 0; // 0-1 day(0) or night(1)
57 protected float m_Clouds = 0; // 0-1 how cloudy it is
58 protected float m_EnvironmentTemperature; //temperature of environment player is in
59 protected float m_Time = 0;
60 protected string m_SurfaceType;
61 protected int m_LiquidType;
62
63 //item temperatures
64 protected float m_ItemTemperatureCoef;
65
66 //
67 protected float m_WaterLevel;
68 protected bool m_IsUnderRoof;
70 protected bool m_IsInWater;
71 protected bool m_IsTempSet;
72 //
73 protected float m_HeatBufferTimer;
74 protected float m_HeatBufferCapPrevious;
75
80
81 protected ref array<int> m_HeadParts;
82 protected ref array<int> m_BodyParts;
83 protected ref array<int> m_FeetParts;
84
86
88 protected float m_UTSAverageTemperature;
90 protected ref SimpleMovingAverage<float> m_UTSAverageTemperatureBuffer;
91 protected ref SimpleMovingAverage<float> m_AverageHeatComfortBuffer;
92
94
95 private bool m_Initialized;
96
97 #ifdef DIAG_DEVELOPER
98 bool m_Debug = false;
99 #endif
100
101 #ifdef ENABLE_LOGGING
102 bool m_DebugLogDryWet = false;
103 bool m_DebugLogItemHeat = false;
104 #endif
105
107 {
108 m_Player = pPlayer;
109 }
110
111 void Init()
112 {
113 m_PlayerSpeed = 0.0;
114 m_WetDryTick = 0.0;
115 m_RoofCheckTimer = 0.0;
116 m_WaterLevel = 0.0;
117 m_HeatComfort = m_Player.GetStatHeatComfort().Get();
118 m_WorldData = g_Game.GetMission().GetWorldData();
119 m_EnvironmentTemperature = m_WorldData.GetBaseEnvTemperatureAtObject(m_Player);
120
121 m_IsUnderRoof = false;
122 m_IsInWater = false;
123 m_SurfaceType = "cp_dirt";
124
125 m_HeatBufferTimer = 0.0;
126
129 m_UTSAverageTemperatureBuffer = new SimpleMovingAverage<float>(10, 0.0);
130 m_AverageHeatComfortBuffer = new SimpleMovingAverage<float>(20, m_HeatComfort);
131
135 InventorySlots.HEADGEAR,
136 InventorySlots.MASK,
137 InventorySlots.EYEWEAR,
138 InventorySlots.GLOVES,
139 InventorySlots.ARMBAND,
140 InventorySlots.BODY,
141 InventorySlots.HIPS,
142 InventorySlots.VEST,
143 InventorySlots.BACK,
144 InventorySlots.LEGS,
145 InventorySlots.FEET
146 };
150 InventorySlots.GLOVES,
151 InventorySlots.ARMBAND,
152 InventorySlots.BODY,
153 InventorySlots.HIPS,
154 InventorySlots.VEST,
155 InventorySlots.BACK,
156 InventorySlots.LEGS,
157 InventorySlots.FEET
158 };
162 InventorySlots.HIPS,
163 InventorySlots.LEGS,
164 InventorySlots.FEET
165 };
169 InventorySlots.FEET,
170 };
171
174 m_HeadParts = new array<int>();
175 m_HeadParts = {
176 InventorySlots.HEADGEAR,
177 InventorySlots.MASK,
178 };
179
180 m_BodyParts = new array<int>();
181 m_BodyParts = {
182 InventorySlots.GLOVES,
183 InventorySlots.HIPS,
184 InventorySlots.BODY,
185 InventorySlots.BACK,
186 InventorySlots.VEST,
187 InventorySlots.MELEE,
188 InventorySlots.SHOULDER
189 };
190
191 m_FeetParts = new array<int>();
192 m_FeetParts = {
193 InventorySlots.LEGS,
194 InventorySlots.FEET,
195 };
196
198 m_EnvironmentSnapshot = new EnvironmentSnapshotData();
199
200 m_Initialized = true;
201 }
202
203 // --------------------------------------------------------------------------------
204
208 void Update(float pDelta)
209 {
210 if (m_Player && m_Initialized)
211 {
212 m_RoofCheckTimer += pDelta;
215 {
216 if ( !IsInsideBuilding() )
218
220 }
221
222 m_Time += pDelta;
224 {
225 m_Time = 0;
226 m_WetDryTick++; // Sets whether it is time to add wetness to items and clothing
227
232
235
241
245 else
247
250 {
251 if (IsWaterContact())
252 {
254 }
255 else if ((IsRaining() || (IsSnowing() && MiscGameplayFunctions.GetCombinedSnowfallWindValue() > SNOWFALL_WIND_COMBINED_THRESHOLD)) && !IsInsideBuilding() && !IsUnderRoof() && !IsChildOfType({Car}))
256 {
258 }
259 else
260 {
262 }
263
265 if ((m_ItemsWetnessMax < GameConstants.STATE_WET) && (m_Player.GetStatWet().Get() == 1))
266 {
267 m_Player.GetStatWet().Set(0);
268 }
269 else if ((m_ItemsWetnessMax >= GameConstants.STATE_WET) && (m_Player.GetStatWet().Get() == 0))
270 {
271 m_Player.GetStatWet().Set(1);
272 }
273
274 m_WetDryTick = 0;
276 }
277 }
278 }
279 }
280
281 // --------------------------------------------------------------------------------
282
287 {
288 return m_IsTempSet;
289 }
290
295 protected float GetPlayerHeat()
296 {
298 return heat;
299 }
300
306 {
307 return m_IsUnderRoof;
308 }
309
314 {
315 return m_Player.IsSoundInsideBuilding();
316 }
317
321 protected bool IsWaterContact()
322 {
323 return m_IsInWater;
324 }
325
330 private bool IsChildOfType(array<typename> typenames)
331 {
332 Object parent = Object.Cast(m_Player.GetParent());
333 if (parent)
334 return parent.IsAnyInherited(typenames);
335
336 return false;
337 }
338
343 private bool IsUnderRoofBuilding()
344 {
346 }
347
351 protected bool IsRaining()
352 {
353 return m_Rain > RAIN_LIMIT_LOW;
354 }
355
359 protected bool IsSnowing()
360 {
362 }
363
370 {
371 if (IsChildOfType({Car}))
372 {
373 CarScript car = CarScript.Cast(m_Player.GetParent());
374 if (car && car.EngineIsOn())
375 {
377 return true;
378 }
379 }
380
382
383 return false;
384 }
385
386 // --------------------------------------------------------------------------------
387
391 protected void CheckUnderRoof()
392 {
394 if (IsChildOfType({Car}))
395 {
396 m_IsUnderRoof = false;
397 m_IsUnderRoofBuilding = false;
398 return;
399 }
400
401 float hitFraction;
402 vector hitPosition, hitNormal;
403 vector from = m_Player.GetPosition();
404 vector to = from + "0 25 0";
405 Object hitObject;
406 PhxInteractionLayers collisionLayerMask = PhxInteractionLayers.ITEM_LARGE|PhxInteractionLayers.BUILDING|PhxInteractionLayers.VEHICLE;
407
408 m_IsUnderRoof = DayZPhysics.RayCastBullet(from, to, collisionLayerMask, null, hitObject, hitPosition, hitNormal, hitFraction);
409
410 m_IsUnderRoofBuilding = hitObject && hitObject.IsInherited(House);
411 }
412
413 // --------------------------------------------------------------------------------
414
421 protected void CheckWaterContact(out float pWaterLevel)
422 {
423 string surfType;
424 int liquidType;
425
426 m_IsInWater = false;
427
428 if (m_Player.PhysicsGetLinkedEntity() || IsChildOfType({Transport}))
429 {
430 m_Player.SetInWater(m_IsInWater);
431 return;
432 }
433
434 if (m_Player.IsSwimming())
435 {
436 g_Game.SurfaceUnderObjectByBoneCorrectedLiquid(m_Player, SurfaceAnimationBone.RightFrontLimb, surfType, liquidType);
437 m_SurfaceType = surfType;
438 m_LiquidType = liquidType;
439
440 m_IsInWater = true;
441 m_Player.SetInWater(m_IsInWater);
442
444 m_Player.GetMovementState(hms);
445
446 pWaterLevel = WATER_LEVEL_MID;
447 if (hms.m_iMovement >= DayZPlayerConstants.MOVEMENTIDX_WALK)
448 pWaterLevel = WATER_LEVEL_HIGH;
449
450 return;
451 }
452
455 {
456 m_IsInWater = false;
457 return;
458 }
459
460 string impact;
461 g_Game.SurfaceUnderObjectExCorrectedLiquid(m_Player, surfType, impact, liquidType);
462
463 switch (liquidType)
464 {
465 case LIQUID_SALTWATER:
466 case LIQUID_WATER:
470 case LIQUID_HOTWATER:
471 pWaterLevel = m_Player.GetCurrentWaterLevel();
472 m_IsInWater = true;
473 break;
474 }
475
477 m_Player.SetInWater(m_IsInWater);
478
480 m_SurfaceType = surfType;
481 m_LiquidType = liquidType;
482
483 }
484
485 // --------------------------------------------------------------------------------
486
493 {
495 return 0.0;
496
497 return g_Game.ConfigGetFloat("CfgSurfaces " + m_SurfaceType + " windModifier");
498 }
499
501 {
503 }
504
506 {
507 return m_TargetHeatComfort;
508 }
509
510 // --------------------------------------------------------------------------------
511
521 {
522 float temperature = m_WorldData.GetTemperature(m_Player, EEnvironmentTemperatureComponent.ALTITUDE | EEnvironmentTemperatureComponent.OVERCAST);
523
524 if (IsWaterContact())
525 {
526 float waterBodyTemperature = m_WorldData.GetLiquidTypeEnviroTemperature(m_LiquidType);
527 temperature = waterBodyTemperature - m_WorldData.m_WaterContactTemperatureModifier;
528
529 return temperature;
530 }
531
533 {
534 temperature += m_WorldData.m_TemperatureInsideBuildingsModifier;
535 }
536 else if (IsChildOfType({Car}))
537 {
539 return temperature;
540 }
541 else if (IsUnderRoof() && !m_IsUnderRoofBuilding)
542 {
545 }
546 else
547 {
549 temperature += m_WorldData.GetTemperatureComponentValue(temperature, EEnvironmentTemperatureComponent.WIND) * GetWindModifierPerSurface();
550 }
551
552 float temperaturesDiff = temperature - m_UTSAverageTemperature;
553 if (temperaturesDiff * (temperaturesDiff - temperature) > 0.0)
554 temperature = m_UTSAverageTemperature;
555
556 return temperature;
557 }
558
559 // --------------------------------------------------------------------------------
560
567 {
568 float wetDelta = 0;
569 if ( IsWaterContact() )
570 {
573 {
574 wetDelta = 1;
575 }
577 {
578 wetDelta = 0.66;
579 }
581 {
582 wetDelta = 0.66;
583 }
585 {
586 wetDelta = 0.33;
587 }
588 }
589 else if (!IsInsideBuilding() && !IsUnderRoof() && !IsChildOfType({Car}))
590 {
591 if (IsRaining())
593
594 if (IsSnowing() && MiscGameplayFunctions.GetCombinedSnowfallWindValue() > SNOWFALL_WIND_COMBINED_THRESHOLD)
596 }
597 else
598 {
600 float tempEffect = Math.Max(m_PlayerHeat + GetEnvironmentTemperature(), 1.0);
601
602 float weatherEffect = ((1 - (m_Fog * GameConstants.ENVIRO_FOG_DRY_EFFECT))) * (1 - (m_Clouds * GameConstants.ENVIRO_CLOUD_DRY_EFFECT));
603 if (weatherEffect <= 0)
604 {
605 weatherEffect = 1.0;
606 }
607
608 wetDelta = -(GameConstants.ENVIRO_DRY_INCREMENT * weatherEffect * tempEffect);
609 if (!IsInsideBuilding())
610 {
611 wetDelta *= 1 + (GameConstants.ENVIRO_WIND_EFFECT * m_Wind);
612 }
613 }
614
615 return wetDelta;
616 }
617
618 // --------------------------------------------------------------------------------
619
626 protected void CollectAndSetPlayerData()
627 {
628 vector playerPos = m_Player.GetPosition();
629 m_PlayerHeightPos = playerPos[1];
630
631 HumanCommandMove hcm = m_Player.GetCommand_Move();
632 if (hcm)
633 {
635 }
636
638 }
639
640 // Each tick updates current environment member variables
645 {
646 Weather weather = g_Game.GetWeather();
647 m_Rain = weather.GetRain().GetActual();
648 m_Snowfall = weather.GetSnowfall().GetActual();
649 m_DayOrNight = g_Game.GetMission().GetWorldData().GetDaytime();
650 m_Fog = weather.GetFog().GetActual();
651 m_Clouds = weather.GetOvercast().GetActual();
652 m_Wind = weather.GetWindMagnitude().GetActual();
653
656 }
657
658 // --------------------------------------------------------------------------------
659
665
670 {
671 float heigthCorrectedTemp = m_WorldData.GetBaseEnvTemperatureAtObject(m_Player);
672 m_Player.SetInColdArea(heigthCorrectedTemp <= GameConstants.COLD_AREA_TEMPERATURE_THRESHOLD);
673 }
674
679 protected void ProcessWetnessByWaterLevel(float pWaterLevel)
680 {
681 if (pWaterLevel >= WATER_LEVEL_HIGH)
683 else if (pWaterLevel >= WATER_LEVEL_MID && pWaterLevel < WATER_LEVEL_HIGH)
685 else if (pWaterLevel >= WATER_LEVEL_LOW && pWaterLevel < WATER_LEVEL_MID)
687 else if (pWaterLevel >= WATER_LEVEL_NONE && pWaterLevel < WATER_LEVEL_LOW)
689 }
690
691 // --------------------------------------------------------------------------------
692
697 protected void ProcessItemsWetness(array<int> pSlotIds)
698 {
699 EntityAI attachment;
700
701 int playerAttachmentCount = m_Player.GetInventory().AttachmentCount();
702
703 #ifdef ENABLE_LOGGING
704 LogDryWetProcess(string.Format("Environment :: ProcessItemsWetness (update interval=%1s)", GameConstants.ENVIRO_TICK_RATE));
705 #endif
706 for (int attIdx = 0; attIdx < playerAttachmentCount; ++attIdx)
707 {
708 attachment = m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
709 if (attachment.IsItemBase())
710 {
711 int attachmentSlotsCount = attachment.GetInventory().GetSlotIdCount();
712 for (int attachmentSlotId = 0; attachmentSlotId < attachmentSlotsCount; ++attachmentSlotId)
713 {
714 int attachmentSlot = attachment.GetInventory().GetSlotId(attachmentSlotId);
715 for (int i = 0; i < pSlotIds.Count(); ++i)
716 {
717 if (attachmentSlot == pSlotIds.Get(i))
718 {
719 ApplyWetnessToItem(ItemBase.Cast(attachment));
720 break;
721 }
722 }
723 }
724 }
725 }
726
727 if (m_Player.GetItemInHands())
728 ApplyWetnessToItem(m_Player.GetItemInHands());
729
730 #ifdef ENABLE_LOGGING
731 LogDryWetProcess("==========");
732 #endif
733 }
734
735 protected void ApplyWetnessToItem(ItemBase pItem)
736 {
737 if (pItem)
738 {
739 ItemBase parentItem;
740 bool isParentWet = false;
741 bool parentContainsLiquid = false;
743
744 if (pItem.GetInventory().GetCurrentInventoryLocation(iLoc))
745 {
746 EntityAI parent = iLoc.GetParent();
747 if (parent)
748 {
749 parentItem = ItemBase.Cast(parent);
750 if (parentItem)
751 {
752 if (parentItem.GetWet() >= GameConstants.STATE_SOAKING_WET)
753 isParentWet = true;
754
755 if ((parentItem.GetLiquidType() != 0) && (parentItem.GetQuantity() > 0))
756 parentContainsLiquid = true;
757 }
758 else
759 isParentWet = true;
760
761 if ((pItem.GetWet() > m_ItemsWetnessMax) && (parent == m_Player))
762 m_ItemsWetnessMax = pItem.GetWet();
763 }
764 }
765
766 if (isParentWet || parentContainsLiquid)
767 {
768 float soakingCoef = 0;
769 if (parentContainsLiquid)
770 {
771 soakingCoef = pItem.GetSoakingIncrement("parentWithLiquid");
772 #ifdef ENABLE_LOGGING
773 LogDryWetProcess(string.Format("%1 (soak coef=%2/s, current wetness=%3) [parent contains liquid]", pItem.GetDisplayName(), soakingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
774 #endif
775 }
776 else if (isParentWet && parentItem)
777 {
778 if (pItem.GetWet() < parentItem.GetWet())
779 soakingCoef = GetWetDelta();
780
781 #ifdef ENABLE_LOGGING
782 LogDryWetProcess(string.Format("%1 (soak coef=%2/s, current wetness=%3) [parent wet]", pItem.GetDisplayName(), soakingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
783 #endif
784 }
785 else
786 {
787 soakingCoef = GetWetDelta();
788 #ifdef ENABLE_LOGGING
789 LogDryWetProcess(string.Format("%1 (soak coef=%2/s, current wetness=%3) [normal]", pItem.GetDisplayName(), soakingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
790 #endif
791 }
792
793 pItem.AddWet(soakingCoef);
794
795 if (pItem.GetInventory().GetCargo())
796 {
797 int inItemCount = pItem.GetInventory().GetCargo().GetItemCount();
798 for (int i = 0; i < inItemCount; ++i)
799 {
800 ItemBase inItem;
801 if (Class.CastTo(inItem, pItem.GetInventory().GetCargo().GetItem(i)))
802 ApplyWetnessToItem(inItem);
803 }
804 }
805
806 int attCount = pItem.GetInventory().AttachmentCount();
807 if (attCount > 0)
808 {
809 for (int attIdx = 0; attIdx < attCount; ++attIdx)
810 {
811 EntityAI attachment = pItem.GetInventory().GetAttachmentFromIndex(attIdx);
812 ItemBase itemAtt = ItemBase.Cast(attachment);
813 if (itemAtt)
814 ApplyWetnessToItem(itemAtt);
815 }
816 }
817 }
818 }
819 }
820 // --------------------------------------------------------------------------------
821
825 protected void ProcessItemsDryness()
826 {
827 EntityAI attachment;
828 ItemBase item;
829
830 int attCount = m_Player.GetInventory().AttachmentCount();
831
832 #ifdef ENABLE_LOGGING
833 LogDryWetProcess(string.Format("Environment :: ProcessItemsDryness (update interval=%1s)", GameConstants.ENVIRO_TICK_RATE));
834 #endif
837
839 {
840 float distance = vector.Distance(m_UTemperatureSources[0].GetPosition(), m_Player.GetPosition());
841 distance = Math.Max(distance, 0.1);
842 drynessData.m_TemperatureSourceDistance = distance;
843 #ifdef ENABLE_LOGGING
844 LogDryWetProcess(string.Format("distance to heatsource: %1 m", distance));
845 #endif
846 }
847
848 for (int attIdx = 0; attIdx < attCount; ++attIdx)
849 {
850 attachment = m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
851 if (attachment && attachment.IsItemBase())
852 {
853 item = ItemBase.Cast(attachment);
854 if (item)
855 ApplyDrynessToItemEx(item, drynessData);
856 }
857 }
858
859 if (m_Player.GetItemInHands())
860 {
861 ApplyDrynessToItemEx(m_Player.GetItemInHands(), drynessData);
862 }
863
864 #ifdef ENABLE_LOGGING
865 LogDryWetProcess("==========");
866 #endif
867 }
868
869 protected void ApplyDrynessToItem(ItemBase pItem)
870 {
872 ApplyDrynessToItemEx(pItem, drynessData);
873 }
874
875 protected void ApplyDrynessToItemEx(ItemBase pItem, EnvironmentDrynessData pDrynessData)
876 {
877 if (pItem)
878 {
879 float dryingIncrement = pItem.GetDryingIncrement("player");
880 if (pDrynessData.m_UseTemperatureSources)
881 dryingIncrement = pItem.GetDryingIncrement("playerHeatSource");
882
883 ItemBase parentItem;
884 bool isParentWet = false;
885 bool parentContainsLiquid = false;
886
888 if (pItem.GetInventory().GetCurrentInventoryLocation(iLoc))
889 {
890 EntityAI parent = iLoc.GetParent();
891 if (parent)
892 {
893 parentItem = ItemBase.Cast(parent);
894 if (parentItem)
895 {
896 if (parentItem.GetWet() >= GameConstants.STATE_SOAKING_WET)
897 isParentWet = true;
898
899 if ((parentItem.GetLiquidType() != 0) && (parentItem.GetQuantity() > 0))
900 parentContainsLiquid = true;
901 }
902
903 if ((pItem.GetWet() > m_ItemsWetnessMax) && (parent == m_Player))
904 m_ItemsWetnessMax = pItem.GetWet();
905 }
906 }
907
908 float dryingCoef = 0;
909
910 if (!isParentWet && !parentContainsLiquid)
911 {
912
913 dryingCoef = (-1 * GameConstants.ENVIRO_TICK_RATE * dryingIncrement) / pDrynessData.m_TemperatureSourceDistance;
914 if (pItem.GetWet() >= GameConstants.STATE_DAMP)
915 {
916 #ifdef ENABLE_LOGGING
917 LogDryWetProcess(string.Format("%1 (dry coef=%2/s, current wetness=%3) [normal]", pItem.GetDisplayName(), dryingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
918 #endif
919 pItem.AddWet(dryingCoef);
920 }
921
922 if (pItem.GetInventory().GetCargo())
923 {
924 int inItemCount = pItem.GetInventory().GetCargo().GetItemCount();
925 for (int i = 0; i < inItemCount; ++i)
926 {
927 ItemBase inItem;
928 if (Class.CastTo(inItem, pItem.GetInventory().GetCargo().GetItem(i)))
929 ApplyDrynessToItemEx(inItem, pDrynessData);
930 }
931 }
932
933 int attCount = pItem.GetInventory().AttachmentCount();
934 if (attCount > 0)
935 {
936 for (int attIdx = 0; attIdx < attCount; ++attIdx)
937 {
938 EntityAI attachment = pItem.GetInventory().GetAttachmentFromIndex(attIdx);
939 ItemBase itemAtt;
940 if (ItemBase.CastTo(itemAtt, attachment))
941 ApplyDrynessToItemEx(itemAtt, pDrynessData);
942 }
943 }
944 }
945
946 if (parentContainsLiquid)
947 {
949 dryingCoef = (GameConstants.ENVIRO_TICK_RATE * pItem.GetSoakingIncrement("parentWithLiquid")) / pDrynessData.m_TemperatureSourceDistance;
950 #ifdef ENABLE_LOGGING
951 LogDryWetProcess(string.Format("%1 (dry coef=%2/s, current wetness=%3) [parent contains liquid]", pItem.GetDisplayName(), dryingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
952 #endif
953 pItem.AddWet(dryingCoef);
954 }
955
956 if (isParentWet)
957 {
959 dryingCoef = (GameConstants.ENVIRO_TICK_RATE * pItem.GetSoakingIncrement("wetParent")) / pDrynessData.m_TemperatureSourceDistance;
960 #ifdef ENABLE_LOGGING
961 LogDryWetProcess(string.Format("%1 (dry coef=%2/s, current wetness=%3) [parent wet]", pItem.GetDisplayName(), dryingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
962 #endif
963 pItem.AddWet(dryingCoef);
964 }
965 }
966 }
967
968 // --------------------------------------------------------------------------------
969
973 protected void ProcessHeatComfort()
974 {
975 float hcPenaltyTotal
976
977 // NEW body parts => splitted
978 float hcBodyPartTotal, hcBodyPart;
979 float hBodyPartTotal, hBodyPart;
980
981 float heatComfortSum = 0.0;
982 float heatItems = 0.0;
983
984 #ifdef ENABLE_LOGGING
985 LogItemHeat("====================");
986 #endif
988 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
990 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
992 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
994 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
996 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
998 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
1000 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
1002 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
1004 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
1005
1012
1013 heatItems = hBodyPartTotal;
1014 heatComfortSum = hcBodyPartTotal;
1015 heatComfortSum += hcPenaltyTotal;
1016
1018 {
1019 if (m_Player.GetStomach().GetStomachVolume() > 0.0)
1020 {
1021 float stomachContentTemperature = m_Player.GetStomach().GetStomachTemperature();
1022 if (stomachContentTemperature < GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT)
1023 {
1024 stomachContentTemperature = Math.Remap(
1025 -10.0,
1028 0.0,
1029 stomachContentTemperature,
1030 );
1031 }
1032 else if (stomachContentTemperature > GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1033 {
1034 stomachContentTemperature = Math.Remap(
1036 70.0,
1037 0.0,
1039 stomachContentTemperature,
1040 );
1041 }
1042 else
1043 stomachContentTemperature = 0.0;
1044
1045 heatComfortSum += stomachContentTemperature * GameConstants.ENVIRO_STOMACH_WEIGHT;
1046 }
1047 }
1048
1049 float targetHeatComfort = (heatComfortSum + heatItems + (GetPlayerHeat() / 100)) + EnvTempToCoef(m_EnvironmentTemperature);
1050
1052 m_EnvironmentSnapshot.m_ClothingHeatComfort = hcBodyPartTotal;
1053 m_EnvironmentSnapshot.m_TargetHeatComfort = targetHeatComfort;
1055
1056 if (m_Player.GetModifiersManager().IsModifierActive(eModifiers.MDF_HEATBUFFER))
1057 targetHeatComfort = Math.Clamp(targetHeatComfort, 0.0, m_Player.GetStatHeatComfort().GetMax());
1058 else
1059 targetHeatComfort = Math.Clamp(targetHeatComfort, m_Player.GetStatHeatComfort().GetMin(), m_Player.GetStatHeatComfort().GetMax());
1060
1061 targetHeatComfort = Math.Round(targetHeatComfort * 100) * 0.01;
1062
1063 float dynamicHeatComfort;
1064
1065 {
1066 float direction = 1.0;
1067 if (targetHeatComfort < 0.0)
1068 direction = -1.0;
1069
1071 dynamicHeatComfort = m_AverageHeatComfortBuffer.Add(targetHeatComfort);
1072 else
1073 dynamicHeatComfort = m_AverageHeatComfortBuffer.Add((Math.AbsFloat(targetHeatComfort) - GameConstants.ENVIRO_HEATCOMFORT_MAX_STEP_SIZE) * direction);
1074 }
1075
1076 dynamicHeatComfort = Math.Round(dynamicHeatComfort * 100) * 0.01;
1077
1078 m_HeatComfort = dynamicHeatComfort;
1079
1080 SetTargetHeatComfort(targetHeatComfort);
1081 m_Player.GetStatHeatComfort().Set(m_HeatComfort);
1082 }
1083
1084 protected void SetTargetHeatComfort(float value)
1085 {
1086 m_TargetHeatComfort = value;
1087 }
1088
1089 protected void SetHeatcomfortDirectly()
1090 {
1092 {
1093 float targetHeatComfort = 0.0;
1094 float dynamicHeatComfort = m_AverageHeatComfortBuffer.Add(targetHeatComfort);
1095
1096 m_HeatComfort = dynamicHeatComfort;
1097
1099 m_Player.GetStatHeatComfort().Set(dynamicHeatComfort);
1100 }
1101 }
1102
1103 // --------------------------------------------------------------------------------
1104
1105 protected void ProcessHeatBuffer(EnvironmentSnapshotData data)
1106 {
1108 {
1109 float applicableHeatbuffer = GetApplicableHeatbuffer();
1110
1112 float heatBufferCap = Math.InverseLerp(0.0, GameConstants.ENVIRO_HEATCOMFORT_WEIGHT_SUMMARY, data.m_ClothingHeatComfort);
1114 m_Player.SetHeatBufferDynamicMax(heatBufferMax);
1115
1116 PlayerStat<float> heatBuffer = m_Player.GetStatHeatBuffer();
1117
1119 if (heatBufferCap < m_HeatBufferCapPrevious)
1120 {
1121 float heatBufferValueCorrection = GameConstants.ENVIRO_PLAYER_HEATBUFFER_INCREASE / (heatBufferMax * ((-GameConstants.ENVIRO_PLAYER_HEATBUFFER_TEMP_AFFECT * data.m_TargetHeatComfort) + 1 ));
1122 heatBuffer.Add(-heatBufferValueCorrection);
1123 m_HeatBufferCapPrevious = heatBufferCap;
1124 }
1125
1126 float increaseRate = 0.0;
1127 float decreaseRate = 0.0;
1128
1129 {
1130 increaseRate = GameConstants.ENVIRO_PLAYER_HEATBUFFER_INCREASE / (heatBufferMax * (( -GameConstants.ENVIRO_PLAYER_HEATBUFFER_TEMP_AFFECT * data.m_TargetHeatComfort) + 1 ));
1131 decreaseRate = GameConstants.ENVIRO_PLAYER_HEATBUFFER_DECREASE / (heatBufferMax * (( GameConstants.ENVIRO_PLAYER_HEATBUFFER_TEMP_AFFECT * data.m_TargetHeatComfort) + 1 ));
1132
1133 float decreaseRateByHeatBufferStageCoef = 1;
1134
1135 if (heatBufferMax > HeatBufferMdfr.STAGE_THRESHOLDS[1])
1136 {
1137 float heatBufferMaxInversed = Math.InverseLerp(HeatBufferMdfr.STAGE_THRESHOLDS[1], 1.0, heatBufferMax);
1138 switch (m_Player.GetHeatBufferStage())
1139 {
1140 case 2:
1141 decreaseRateByHeatBufferStageCoef = Math.Lerp(
1144 heatBufferMaxInversed,
1145 );
1146 break;
1147 case 1:
1148 decreaseRateByHeatBufferStageCoef = Math.Lerp(
1151 heatBufferMaxInversed,
1152 );
1153 break;
1154 }
1155 }
1156 else
1157 {
1158 decreaseRateByHeatBufferStageCoef = GameConstants.ENVIRO_PLAYER_HEATBUFFER_STAGE_RATELIMIT[1][0];
1159 }
1160
1161 decreaseRate *= decreaseRateByHeatBufferStageCoef;
1162
1163 if (m_IsInWater)
1165 }
1166
1168 {
1169 if (m_Player.GetModifiersManager().IsModifierActive(eModifiers.MDF_HEATBUFFER))
1170 {
1171 if (m_HeatBufferTimer >= 1.0)
1172 heatBuffer.Add(-decreaseRate);
1173 else
1174 m_HeatBufferTimer = 1.0;
1175 }
1176 else
1177 {
1178 m_HeatBufferTimer = 0.0;
1179 if (applicableHeatbuffer > 0.0)
1180 heatBuffer.Add(-decreaseRate);
1181 else if (applicableHeatbuffer != 0.0 && !m_Player.GetModifiersManager().IsModifierActive(eModifiers.MDF_HEATBUFFER))
1182 heatBuffer.Set(0.0);
1183 }
1184 }
1185 else
1186 {
1187 if (m_HeatComfort > PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING && m_UTSAverageTemperature > 0) // m_UTSAverageTemperature can be negative
1188 {
1189 if (applicableHeatbuffer < heatBufferMax)
1190 {
1191 heatBuffer.Add(increaseRate);
1192 m_HeatBufferCapPrevious = heatBufferCap;
1193 }
1194 }
1195 else if (applicableHeatbuffer > 0.0)
1196 heatBuffer.Add(-decreaseRate);
1197 else if (applicableHeatbuffer != 0.0 && !m_Player.GetModifiersManager().IsModifierActive(eModifiers.MDF_HEATBUFFER))
1198 heatBuffer.Set(0.0);
1199
1200 m_HeatBufferTimer = 0.0;
1201 }
1202 }
1203 }
1204
1205 protected float GetApplicableHeatbuffer()
1206 {
1207 PlayerStat<float> heatBuffer = m_Player.GetStatHeatBuffer();
1208 float applicableHeatbuffer = Math.Round((heatBuffer.Get() / heatBuffer.GetMax()) * 1000) * 0.001;
1209
1210 return applicableHeatbuffer;
1211 }
1212
1213 // --------------------------------------------------------------------------------
1214
1219 protected void ProcessItemsTemperature(array<int> pBodyPartIds)
1220 {
1221 EntityAI attachment;
1222 ItemBase item;
1223
1224 int attCount = m_Player.GetInventory().AttachmentCount();
1225 for (int attIdx = 0; attIdx < attCount; ++attIdx)
1226 {
1227 attachment = m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
1228 item = ItemBase.Cast(attachment);
1229 int attachmentSlot = attachment.GetInventory().GetSlotId(0);
1230
1232 for (int i = 0; i < pBodyPartIds.Count(); ++i)
1233 {
1234 if (attachmentSlot == pBodyPartIds[i])
1235 {
1236 float heatPermCoef = item.GetHeatPermeabilityCoef();
1237 //first handle the item itself, if necessary
1238 if (item.CanHaveTemperature() && !item.IsSelfAdjustingTemperature())
1239 SetProcessedItemTemperature(item, heatPermCoef);
1240
1241 ProcessItemHierarchyRecursive(item, heatPermCoef);
1242 }
1243 }
1244 }
1245 }
1246
1251 {
1252 ItemBase item = m_Player.GetItemInHands();
1253 if (item)
1254 {
1255 float heatPermCoef = item.GetHeatPermeabilityCoef();
1256 //first handle the item itself, if necessary
1257 if (item.CanHaveTemperature() && !item.IsSelfAdjustingTemperature())
1258 SetProcessedItemTemperature(item,heatPermCoef);
1259
1260 ProcessItemHierarchyRecursive(item,heatPermCoef);
1261 }
1262 }
1263
1264 protected void ProcessItemHierarchyRecursive(ItemBase item, float heatPermeabilityCoef = 1.0)
1265 {
1266 float heatPermCoef = heatPermeabilityCoef;
1267
1268 // go through any attachments and cargo, recursive
1269 int inventoryAttCount = item.GetInventory().AttachmentCount();
1270 if (inventoryAttCount > 0)
1271 {
1272 ItemBase attachmentItem;
1273 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
1274 {
1275 if (Class.CastTo(attachmentItem,item.GetInventory().GetAttachmentFromIndex(inAttIdx)))
1276 {
1277 heatPermCoef = heatPermeabilityCoef;
1278 heatPermCoef *= attachmentItem.GetHeatPermeabilityCoef();
1279
1280 if (attachmentItem.CanHaveTemperature() && !attachmentItem.IsSelfAdjustingTemperature())
1281 {
1282 SetProcessedItemTemperature(attachmentItem,heatPermCoef);
1283 }
1284
1285 ProcessItemHierarchyRecursive(attachmentItem,heatPermCoef);
1286 }
1287 }
1288 }
1289
1290 if (item.GetInventory().GetCargo())
1291 {
1292 int inventoryItemCount = item.GetInventory().GetCargo().GetItemCount();
1293 if (inventoryItemCount > 0)
1294 {
1295 ItemBase inventoryItem;
1296 for (int j = 0; j < inventoryItemCount; ++j)
1297 {
1298 if (Class.CastTo(inventoryItem,item.GetInventory().GetCargo().GetItem(j)))
1299 {
1300 heatPermCoef = heatPermeabilityCoef;
1301 heatPermCoef *= inventoryItem.GetHeatPermeabilityCoef();
1302
1303 if (inventoryItem.CanHaveTemperature() && !inventoryItem.IsSelfAdjustingTemperature())
1304 {
1305 SetProcessedItemTemperature(inventoryItem,heatPermCoef);
1306 }
1307
1308 ProcessItemHierarchyRecursive(inventoryItem,heatPermCoef);
1309 }
1310 }
1311 }
1312 }
1313 }
1314
1315 protected void SetProcessedItemTemperature(ItemBase item, float heatPermeabilityCoef = 1.0)
1316 {
1317 float targetTemperature = GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE;
1318 bool globalCooling = true;
1320 if (m_Player.IsSwimming())
1321 {
1323 targetTemperature = m_WorldData.GetLiquidTypeEnviroTemperature(m_LiquidType);
1324 globalCooling = false;
1325 }
1326
1327 if (item.GetTemperature() != targetTemperature || !item.IsFreezeThawProgressFinished())
1328 {
1329 TemperatureDataInterpolated temperatureData = new TemperatureDataInterpolated(
1330 targetTemperature,
1331 ETemperatureAccessTypes.ACCESS_INVENTORY,
1334 heatPermeabilityCoef,
1335 );
1336 temperatureData.m_UseGlobalCooling = globalCooling;
1337
1338 item.SetTemperatureEx(temperatureData);
1339 }
1340 }
1341
1342 // --------------------------------------------------------------------------------
1343
1344 protected float EnvTempToCoef(float pTemp)
1345 {
1347 }
1348
1356 protected void BodyPartHeatProperties(int pBodyPartId, float pCoef, out float pHeatComfort, out float pHeat)
1357 {
1358 pHeatComfort = 0;
1359 pHeat = 0;
1360
1361 GameInventory playerInventory = m_Player.GetInventory();
1362 int attCount = playerInventory.AttachmentCount();
1363 for (int attIdx = 0; attIdx < attCount; ++attIdx)
1364 {
1365 EntityAI attachment = playerInventory.GetAttachmentFromIndex(attIdx);
1366 if (attachment.IsClothing())
1367 {
1368 ItemBase item = ItemBase.Cast(attachment);
1369 int attachmentSlot = attachment.GetInventory().GetSlotId(0);
1370
1371 if (attachmentSlot == pBodyPartId)
1372 {
1373 #ifdef ENABLE_LOGGING
1374 LogItemHeat(string.Format("BodyPartHeatProperties (%1)", EnumTools.EnumToString(InventorySlots, pBodyPartId)));
1375 #endif
1376
1377 float itemHeatcomfort = 0;
1378 float itemTemperature = 0;
1379
1380 // go through any attachments and cargo (only current level, ignore nested containers - they isolate)
1381 GameInventory itemInventory = item.GetInventory();
1382 int inventoryAttCount = itemInventory.AttachmentCount();
1383 if (inventoryAttCount > 0)
1384 {
1385 #ifdef ENABLE_LOGGING
1386 LogItemHeat(string.Format("attachments:"), false);
1387 #endif
1388 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
1389 {
1390 EntityAI inAttachment = itemInventory.GetAttachmentFromIndex(inAttIdx);
1391 ItemBase attachmentItem = ItemBase.Cast(inAttachment);
1392 if (attachmentItem && attachmentItem.CanHaveTemperature())
1393 {
1394 itemTemperature = attachmentItem.GetTemperature();
1395 if (itemTemperature < GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT || itemTemperature > GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1396 {
1397 itemHeatcomfort = NormalizedTemperature(itemTemperature) * attachmentItem.GetQuantityNormalizedScripted() * attachmentItem.GetTemperaturePerQuantityWeight();
1398 #ifdef ENABLE_LOGGING
1399 LogItemHeat(string.Format("%1: temperature=%2 heat=%3", attachmentItem, itemTemperature, pHeat), true);
1400 #endif
1401 pHeat += itemHeatcomfort;
1402 }
1403 }
1404 }
1405 }
1406
1407 CargoBase inventoryItemCargo = itemInventory.GetCargo();
1408 if (inventoryItemCargo)
1409 {
1410 int inventoryItemCount = inventoryItemCargo.GetItemCount();
1411
1412 if (inventoryItemCount > 0)
1413 {
1414 #ifdef ENABLE_LOGGING
1415 LogItemHeat(string.Format("cargo:"), false);
1416 #endif
1417 for (int j = 0; j < inventoryItemCount; ++j)
1418 {
1419 ItemBase inventoryItem = ItemBase.Cast(inventoryItemCargo.GetItem(j));
1420 if (inventoryItem && inventoryItem.CanHaveTemperature())
1421 {
1422 itemTemperature = inventoryItem.GetTemperature();
1423 if (itemTemperature < GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT || itemTemperature > GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1424 {
1425 itemHeatcomfort = NormalizedTemperature(itemTemperature) * inventoryItem.GetQuantityNormalizedScripted() * inventoryItem.GetTemperaturePerQuantityWeight();
1426 #ifdef ENABLE_LOGGING
1427 LogItemHeat(string.Format("%1: temperature=%2 heat=%3", inventoryItem, itemTemperature, itemHeatcomfort), true);
1428 #endif
1429 pHeat += itemHeatcomfort;
1430 }
1431 }
1432 }
1433 }
1434 }
1435
1436 pHeatComfort = MiscGameplayFunctions.GetCurrentItemHeatIsolation(item) * pCoef;
1437
1438 #ifdef ENABLE_LOGGING
1439 LogItemHeat(string.Format("overall heat from items=%1 (coef applied)", pHeat));
1440 LogItemHeat("");
1441 #endif
1442
1443 break;
1444 }
1445 }
1446 }
1447 }
1448
1455 protected float NakedBodyPartHeatComfortPenalty(int pBodyPartSlotId, float pCoef)
1456 {
1457 float penalty = 0.0;
1458
1460 {
1462 {
1464 penalty *= pCoef;
1465 }
1466 }
1467
1468 return penalty;
1469 }
1470
1471 // --------------------------------------------------------------------------------
1472
1477 {
1478 m_UTemperatureSources.Clear();
1479
1480 // Calculate min and max positions of the box
1481 vector pos = m_Player.GetPosition();
1484
1485 array<EntityAI> nearestObjects = {};
1486 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.STATIC|QueryFlags.DYNAMIC); //STATIC catches area effects and other static (or 'static') sources
1487
1488 foreach (EntityAI nearestEntity : nearestObjects)
1489 {
1490 if (nearestEntity.IsUniversalTemperatureSource() && nearestEntity != m_Player)
1491 {
1493 if (!nearestEntity.GetUniversalTemperatureSource().GetLambda().AffectsPlayer())
1494 continue;
1495
1497 if (vector.DistanceSq(pos, nearestEntity.GetPosition()) > Math.SqrFloat(nearestEntity.GetUniversalTemperatureSource().GetMaxRange()))
1498 continue;
1499
1500 m_UTemperatureSources.Insert(nearestEntity.GetUniversalTemperatureSource());
1501 }
1502 }
1503
1504 if (m_Player.GetItemInHands() && m_Player.GetItemInHands().IsUniversalTemperatureSource())
1505 m_UTemperatureSources.Insert(m_Player.GetItemInHands().GetUniversalTemperatureSource());
1506 }
1507
1512 {
1513 int UTScount = m_UTemperatureSources.Count();
1514 if (UTScount == 0)
1515 {
1521
1522 return;
1523 }
1524
1525 array<float> utsTemperatures = new array<float>();
1526
1527 // get temperature from the source (based on distance), save it for min/max filtering
1528 float itemCoefAverage = 0.0;
1529 foreach (UTemperatureSource tempSource : m_UTemperatureSources)
1530 {
1531 utsTemperatures.Insert(CalcTemperatureFromTemperatureSource(tempSource));
1532 itemCoefAverage += tempSource.GetTemperatureItemCoef();
1533 }
1534 itemCoefAverage /= UTScount;
1535 SetItemHeatingCoef(itemCoefAverage);
1536
1537 float min = MiscGameplayFunctions.GetMinValue(utsTemperatures);
1538 float max = MiscGameplayFunctions.GetMaxValue(utsTemperatures);
1539
1540 if (max > 0 && min < 0)
1541 {
1544 }
1545 else
1546 {
1548 }
1549
1550 if (m_HasTemperatureSources == false)
1552
1554 }
1555
1556 protected void SetItemHeatingCoef(float val)
1557 {
1559 }
1560
1564 protected void OnTemperatureSourcesEnter();
1565
1570
1575
1576 float CalcTemperatureFromTemperatureSource(notnull UTemperatureSource uts)
1577 {
1578 float distance = vector.Distance(m_Player.GetPosition(), uts.GetPosition());
1579 distance = Math.Max(distance, 0.1); //min distance cannot be 0 (division by zero)
1580 float temperature = 0;
1581
1583 if (distance > uts.GetFullRange())
1584 {
1585 float distFactor = Math.InverseLerp(uts.GetMaxRange(), uts.GetFullRange(), distance);
1586 temperature = uts.GetTemperatureCap() * distFactor;
1587 }
1588 else
1589 {
1590 temperature = uts.GetTemperatureCap();
1591 }
1592
1593 return temperature;
1594 }
1595
1596 // --------------------------------------------------------------------------------
1597
1599 #ifdef DIAG_DEVELOPER
1600 EnvDebugData GetEnvDebugData()
1601 {
1602 EnvDebugData data = new EnvDebugData();
1603 data.Synch(this, m_Player);
1604 return data;
1605 }
1606
1607 void ShowEnvDebugPlayerInfo(bool enabled)
1608 {
1609 EnvDebugData data = GetEnvDebugData();
1610 DisplayEnvDebugPlayerInfo(enabled, data);
1611 }
1612
1613 static void DisplayEnvDebugPlayerInfo(bool enabled, EnvDebugData data)
1614 {
1615 int windowPosX = 10;
1616 int windowPosY = 200;
1617
1618 Object obj;
1619
1620 DbgUI.Begin("Player stats", windowPosX, windowPosY);
1621 if ( enabled )
1622 {
1623 DbgUI.Text(string.Format("Heat comfort(target): %1", data.m_PlayerData.m_HeatComfortTarget));
1624 DbgUI.Text(string.Format("Heat comfort(dynamic): %1", data.m_PlayerData.m_HeatComfortDynamic));
1625 DbgUI.Text(string.Format("Inside: %1 (%2)", data.m_PlayerData.m_Inside, data.m_PlayerData.m_Surface));
1626 DbgUI.Text(string.Format("Under roof: %1 (%2)", data.m_PlayerData.m_UnderRoof, data.m_PlayerData.m_UnderRoofTimer));
1627 if ( data.m_PlayerData.m_WaterLevel > 0 )
1628 {
1629 DbgUI.Text(string.Format("Water Level: %1", data.m_PlayerData.m_WaterLevel));
1630 }
1631
1632 }
1633 DbgUI.End();
1634
1635 DbgUI.Begin("Weather stats:", windowPosX, windowPosY + 200);
1636 if ( enabled )
1637 {
1638 DbgUI.Text(string.Format("Env temperature (base): %1", data.m_MiscData.m_TemperatureBase));
1639 DbgUI.Text(string.Format("Env temperature (height corrected): %1", data.m_MiscData.m_HeightCorrectedTemperature));
1640 DbgUI.Text(string.Format("Env temperature (modfied): %1", data.m_MiscData.m_TemperatureModified));
1641 DbgUI.Text(string.Format("Wind magnitude(surface mult): %1 (x%2)", data.m_WeatherData.m_Wind, data.m_WeatherData.m_WindModifier));
1642 DbgUI.Text(string.Format("Rain: %1", data.m_WeatherData.m_Rain));
1643 DbgUI.Text(string.Format("Snow: %1", data.m_WeatherData.m_Snowfall));
1644 DbgUI.Text(string.Format("Datetime: %1", WorldDataDaytime.ToString(g_Game.GetMission().GetWorldData().GetDaytime())));
1645 DbgUI.Text(string.Format("Fog: %1", data.m_WeatherData.m_Fog));
1646 DbgUI.Text(string.Format("Clouds: %1", data.m_WeatherData.m_Clouds));
1647 DbgUI.Text(string.Format("Wet delta: %1", data.m_MiscData.m_WetDelta));
1648 }
1649 DbgUI.End();
1650 }
1651
1652 void FillDebugWeatherData(EnvDebugWeatherData data)
1653 {
1654 data.m_Wind = m_Wind;
1655 data.m_WindModifier = GetWindModifierPerSurface();
1656 data.m_Rain = m_Rain;
1657 data.m_Snowfall = m_Snowfall;
1658 data.m_Fog = m_Fog;
1659 data.m_Clouds = m_Clouds;
1660 }
1661 #endif
1662
1664 {
1665 string message;
1666 message += "Player stats";
1667 message += "\nHeat comfort(target): " + GetTargetHeatComfort().ToString();
1668 message += "\nHeat comfort(dynamic): " + m_HeatComfort.ToString();
1669
1670 int liquidType;
1671 string impact, surfaceType;
1672 g_Game.SurfaceUnderObjectExCorrectedLiquid(m_Player, surfaceType, impact, liquidType);
1673
1674 message += "\nInside: " + IsInsideBuilding().ToString();
1675 message += "\nSurface: " + surfaceType;
1676 message += "\nLiquid: " + liquidType;
1677 message += "\nUnder roof: " + m_IsUnderRoof.ToString() + " (" + GetNextRoofCheck() + ")";
1679 {
1680 message += "\nWater Level: " + m_WaterLevel;
1681 }
1682
1683 message += "\n\nWeather stats";
1684 message += "\nEnv temperature (base): " + m_WorldData.GetBaseEnvTemperature().ToString();
1685 message += "\nEnv temperature (height corrected): " + m_WorldData.GetBaseEnvTemperatureAtObject(m_Player);
1686 message += "\nEnv temperature (modified): " + m_EnvironmentTemperature.ToString();
1687 message += "\nWind: " + m_Wind.ToString() + " (x" + GetWindModifierPerSurface() + ")";
1688 message += "\nRain: " + m_Rain.ToString();
1689 message += "\nSnow: " + m_Snowfall.ToString();
1690 message += "\nDatetime: " + WorldDataDaytime.ToString(m_DayOrNight);
1691 message += "\nFog: " + m_Fog.ToString();
1692 message += "\nClouds: " + m_Clouds.ToString();
1693 message += "\nWet delta: " + GetWetDelta().ToString();
1694
1695 return message;
1696 }
1697
1702
1704 {
1706 {
1707 return m_WaterLevel;
1708 }
1709
1710 return 0.0;
1711 }
1712
1714 {
1715 if (temperature >= lowerLimit && temperature <= upperLimit)
1716 return true;
1717
1718 return false;
1719 }
1720
1721 private float NormalizedTemperature(float temperature, float lowerLimit = GameConstants.ENVIRO_LOW_TEMP_LIMIT, float upperLimit = GameConstants.ENVIRO_HIGH_TEMP_LIMIT)
1722 {
1724 return 0.0;
1725
1727 return Math.Clamp(Math.InverseLerp(lowerLimit, GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT, temperature), -1.0, -0.1);
1728
1730 return Math.Clamp(Math.InverseLerp(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT, upperLimit, temperature), 0.1, 1.0);
1731
1732 // neutral zone
1733 return 0.0;
1734 }
1735
1736 #ifdef ENABLE_LOGGING
1737 private void LogDryWetProcess(string message, bool indented = false)
1738 {
1739 if (m_DebugLogDryWet)
1740 {
1741 string indentation = "";
1742 if (indented)
1743 indentation = "|--";
1744
1745 Debug.Log(string.Format("%1 %2", indentation, message));
1746 }
1747 }
1748 #endif
1749
1750 #ifdef ENABLE_LOGGING
1751 private void LogItemHeat(string message, bool indented = false)
1752 {
1753 if (m_DebugLogItemHeat)
1754 {
1755 string indentation = "";
1756 if (indented)
1757 indentation = "|--";
1758
1759 Debug.Log(string.Format("%1 %2", indentation, message));
1760 }
1761 }
1762 #endif
1763
1764 // --------------------------------------------------------------------------------
1765
1767 protected float m_HeatSourceTemp;
1768 protected ref SimpleMovingAverage<float> m_WindAverageBuffer;
1769 protected ref EnvironmentSnapshotData m_EnvironmentSnapshot;
1770
1771 void Init(PlayerBase pPlayer)
1772 {
1773 Init();
1774 }
1775
1776 protected bool OverridenHeatComfort(out float value);
1777 void AddToEnvironmentTemperature(float pTemperature);
1778
1779 protected void ProcessItemsHeat()
1780 {
1781 // for backward combatibility only
1783 }
1784
1785 protected void ProcessWetnessByRain()
1786 {
1788 }
1789
1790 // Returns amount of deg C air temperature should be lowered by, based on player's height above water level
1792 {
1793 float temperature_reduction = Math.Max(0, (m_PlayerHeightPos * m_WorldData.m_TemperaturePerHeightReductionModifier));
1794 return temperature_reduction;
1795 }
1796
1798 protected void BodyPartHeatProperties(array<int> pBodyPartIds, float pCoef, out float pHeatComfort, out float pHeat)
1799 {
1800 pHeatComfort = 0;
1801 pHeat = 0;
1802
1803 if (pBodyPartIds.Count() > 0)
1804 {
1805 #ifdef ENABLE_LOGGING
1806 LogItemHeat(string.Format("BodyPartHeatProperties (%1)", EnumTools.EnumToString(InventorySlots, pBodyPartIds[0])));
1807 #endif
1808
1809 int attCount = m_Player.GetInventory().AttachmentCount();
1810 for (int attIdx = 0; attIdx < attCount; ++attIdx)
1811 {
1812 EntityAI attachment = m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
1813 if (attachment.IsClothing())
1814 {
1815 ItemBase item = ItemBase.Cast(attachment);
1816 int attachmentSlot = attachment.GetInventory().GetSlotId(0);
1817
1819 for (int i = 0; i < pBodyPartIds.Count(); ++i)
1820 {
1821 if (attachmentSlot == pBodyPartIds[i])
1822 {
1823 float heatIsoMult = 1.0;
1824 if (attachmentSlot == InventorySlots.BACK)
1826 else if (attachmentSlot == InventorySlots.VEST)
1828
1829 pHeatComfort += heatIsoMult * MiscGameplayFunctions.GetCurrentItemHeatIsolation(item);
1830
1831 float itemHeatcomfort = 0;
1832 float itemTemperature = 0;
1833
1834 // go through any attachments and cargo (only current level, ignore nested containers - they isolate)
1835 int inventoryAttCount = item.GetInventory().AttachmentCount();
1836 if (inventoryAttCount > 0)
1837 {
1838 #ifdef ENABLE_LOGGING
1839 LogItemHeat(string.Format("attachments:"), false);
1840 #endif
1841 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
1842 {
1843 EntityAI inAttachment = item.GetInventory().GetAttachmentFromIndex(inAttIdx);
1844 ItemBase attachmentItem = ItemBase.Cast(inAttachment);
1845 if (attachmentItem && attachmentItem.CanHaveTemperature())
1846 {
1847 itemTemperature = attachmentItem.GetTemperature();
1848 if (itemTemperature < GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT || itemTemperature > GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1849 {
1850 itemHeatcomfort = NormalizedTemperature(itemTemperature) * attachmentItem.GetQuantityNormalizedScripted() * attachmentItem.GetTemperaturePerQuantityWeight();
1851 #ifdef ENABLE_LOGGING
1852 LogItemHeat(string.Format("%1: temperature=%2 heat=%3", attachmentItem, itemTemperature, pHeat), true);
1853 pHeat += itemHeatcomfort;
1854 #endif
1855 }
1856 }
1857 }
1858 }
1859 if (item.GetInventory().GetCargo())
1860 {
1861 int inventoryItemCount = item.GetInventory().GetCargo().GetItemCount();
1862
1863 if (inventoryItemCount > 0)
1864 {
1865 #ifdef ENABLE_LOGGING
1866 LogItemHeat(string.Format("cargo:"), false);
1867 #endif
1868 for (int j = 0; j < inventoryItemCount; ++j)
1869 {
1870 ItemBase inventoryItem = ItemBase.Cast(item.GetInventory().GetCargo().GetItem(j));
1871 if (inventoryItem && inventoryItem.CanHaveTemperature())
1872 {
1873 itemTemperature = inventoryItem.GetTemperature();
1874 if (itemTemperature < GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT || itemTemperature > GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1875 {
1876 itemHeatcomfort = NormalizedTemperature(itemTemperature) * inventoryItem.GetQuantityNormalizedScripted() * inventoryItem.GetTemperaturePerQuantityWeight();
1877 #ifdef ENABLE_LOGGING
1878 LogItemHeat(string.Format("%1: temperature=%2 heat=%3", inventoryItem, itemTemperature, itemHeatcomfort), true);
1879 #endif
1880 pHeat += itemHeatcomfort;
1881 }
1882 }
1883 }
1884 }
1885 }
1886 }
1887 }
1888 }
1889 }
1890
1891 pHeatComfort += (pHeatComfort / pBodyPartIds.Count()) * pCoef;
1892
1893 #ifdef ENABLE_LOGGING
1894 LogItemHeat(string.Format("overall heat from items=%1 (coef applied)", pHeat));
1895 LogItemHeat("");
1896 #endif
1897 }
1898 }
1899
1901 {
1902 EnvironmentSnapshotData data = new EnvironmentSnapshotData();
1903 data.m_TargetHeatComfort = m_TargetHeatComfort;
1904
1905 m_EnvironmentSnapshot = data;
1906 }
1907
1909 protected void ProcessHeatBuffer(float heatComfortCloths)
1910 {
1911 m_EnvironmentSnapshot.m_ClothingHeatComfort = heatComfortCloths;
1912 m_EnvironmentSnapshot.m_TargetHeatComfort = m_TargetHeatComfort;
1913
1915 }
1916
1918 protected float WindEffectTemperatureValue(float temperatureInput)
1919 {
1920 float output = 0.0;
1921
1923 output = output * m_Wind * m_WorldData.GetWindCoef();
1924
1925 return -output;
1926 }
1927
1929 {
1930 return m_DayOrNight;
1931 }
1932
1933 protected bool IsInsideVehicle()
1934 {
1935 return IsChildOfType({Car});
1936 }
1937}
1938
1939#ifdef DIAG_DEVELOPER
1940class EnvDebugPlayerData : Param
1941{
1942 float m_HeatComfortDynamic;
1943 float m_HeatComfortTarget;
1944 bool m_Inside;
1945 string m_Surface;
1946 bool m_UnderRoof;
1947 int m_UnderRoofTimer;
1948 float m_WaterLevel;
1949
1950 void Synch(Environment env, PlayerBase player)
1951 {
1952 m_HeatComfortTarget = env.GetTargetHeatComfort();
1953 m_HeatComfortDynamic = player.GetStatHeatComfort().Get();
1954 m_Inside = env.IsInsideBuilding();
1955 m_Surface = player.GetSurfaceType();
1956 m_UnderRoof = env.IsUnderRoof();
1957 m_UnderRoofTimer = env.GetNextRoofCheck();
1958 m_WaterLevel = env.GetWaterLevel();
1959 }
1960
1961 override bool Serialize(Serializer ctx)
1962 {
1963 return (
1964 ctx.Write(m_HeatComfortTarget) && ctx.Write(m_HeatComfortDynamic) && ctx.Write(m_Inside) && ctx.Write(m_Surface) && ctx.Write(m_UnderRoof) && ctx.Write(m_UnderRoofTimer) && ctx.Write(m_WaterLevel));
1965 }
1966
1967 override bool Deserializer(Serializer ctx)
1968 {
1969 return ctx.Read(m_HeatComfortTarget) && ctx.Read(m_HeatComfortDynamic) && ctx.Read(m_Inside) && ctx.Read(m_Surface) && ctx.Read(m_UnderRoof) && ctx.Read(m_UnderRoofTimer) && ctx.Read(m_WaterLevel);
1970 }
1971}
1972
1973class EnvDebugMiscData : Param
1974{
1975 float m_TemperatureBase;
1976 float m_TemperatureModified;
1977 float m_HeightCorrectedTemperature;
1978 float m_WetDelta;
1979
1980 void Synch(Environment env)
1981 {
1982 m_TemperatureBase = g_Game.GetMission().GetWorldData().GetBaseEnvTemperature();
1983 m_TemperatureModified = env.GetTemperature();
1984 m_HeightCorrectedTemperature = m_TemperatureBase - env.GetTemperatureHeightCorrection();
1985 m_WetDelta = env.GetWetDelta();
1986 }
1987
1988 override bool Serialize(Serializer ctx)
1989 {
1990 return ctx.Write(m_TemperatureBase) && ctx.Write(m_TemperatureModified) && ctx.Write(m_HeightCorrectedTemperature) && ctx.Write(m_WetDelta);
1991 }
1992
1993 override bool Deserializer(Serializer ctx)
1994 {
1995 return ctx.Read(m_TemperatureBase) && ctx.Read(m_TemperatureModified) && ctx.Read(m_HeightCorrectedTemperature) && ctx.Read(m_WetDelta);
1996 }
1997}
1998
1999class EnvDebugWeatherData : Param
2000{
2001 float m_Wind;
2002 float m_WindModifier;
2003 float m_Rain;
2004 float m_Snowfall;
2005 float m_Fog;
2006 float m_Clouds;
2007
2008 void Synch(Environment env)
2009 {
2010 env.FillDebugWeatherData(this);
2011 }
2012
2013 override bool Serialize(Serializer ctx)
2014 {
2015 return ctx.Write(m_Wind) && ctx.Write(m_WindModifier) && ctx.Write(m_Rain) && ctx.Write(m_Snowfall) && ctx.Write(m_Fog) && ctx.Write(m_Clouds);
2016 }
2017
2018 override bool Deserializer(Serializer ctx)
2019 {
2020 return ctx.Read(m_Wind) && ctx.Read(m_WindModifier) && ctx.Read(m_Rain) && ctx.Read(m_Snowfall) && ctx.Read(m_Fog) && ctx.Read(m_Clouds);
2021 }
2022}
2023
2024class EnvDebugData : Param
2025{
2026 ref EnvDebugPlayerData m_PlayerData = new EnvDebugPlayerData();
2027 ref EnvDebugMiscData m_MiscData = new EnvDebugMiscData();
2028 ref EnvDebugWeatherData m_WeatherData = new EnvDebugWeatherData();
2029
2030 void Synch(Environment env, PlayerBase player)
2031 {
2032 m_PlayerData.Synch(env, player);
2033 m_MiscData.Synch(env);
2034 m_WeatherData.Synch(env);
2035 }
2036
2037 override bool Serialize(Serializer ctx)
2038 {
2039 return m_PlayerData.Serialize(ctx) && m_MiscData.Serialize(ctx) && m_WeatherData.Serialize(ctx);
2040 }
2041
2042 override bool Deserializer(Serializer ctx)
2043 {
2044 return m_PlayerData.Deserializer(ctx) && m_MiscData.Deserializer(ctx) && m_WeatherData.Deserializer(ctx);
2045 }
2046}
2047#endif
void Serialize()
map m_Player
string Debug()
Определения CachedEquipmentStorageBase.c:29
DayZGame g_Game
Определения DayZGame.c:3942
override Widget Init()
Определения DayZGame.c:127
PhxInteractionLayers
Определения DayZPhysics.c:2
void DayZPlayerUtils()
cannot be instantiated
Определения DayZPlayerUtils.c:465
QueryFlags
Определения DayZPlayerUtils.c:2
EEnvironmentTemperatureComponent
bool m_IsInWater
Определения Environment.c:70
ref EnvironmentSnapshotData m_EnvironmentSnapshot
Определения Environment.c:1769
bool IsNeutralTemperature(float temperature, float lowerLimit=GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT, float upperLimit=GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
Определения Environment.c:1713
void CollectAndSetEnvironmentData()
Sets actual weather related values for further use (rain, snow, wind, etc.)
Определения Environment.c:644
ref SimpleMovingAverage< float > m_UTSAverageTemperatureBuffer
Определения Environment.c:90
ref array< UTemperatureSource > m_UTemperatureSources
Определения Environment.c:89
void SetTargetHeatComfort(float value)
Определения Environment.c:1084
int GetNextRoofCheck()
Определения Environment.c:1698
float GetTemperatureHeightCorrection()
Определения Environment.c:1791
bool IsChildOfType(array< typename > typenames)
Returns true if character is child of given parent type(s)
Определения Environment.c:330
bool IsWaterContact()
Is character in contact with water body? (periodically checked - GameConstants.ENVIRO_TICK_RATE).
Определения Environment.c:321
ref array< int > m_SlotIdsComplete
Определения Environment.c:76
int m_HeatComfortBehaviorCategory
Определения Environment.c:93
bool IsInsideBuilding()
Is character inside building? (periodically checked - GameConstants.ENVIRO_TICK_ROOF_RC_CHECK).
Определения Environment.c:313
float m_HeatBufferTimer
Определения Environment.c:73
float m_UTSAverageTemperature
Определения Environment.c:88
float CalcTemperatureFromTemperatureSource(notnull UTemperatureSource uts)
Определения Environment.c:1576
float m_Time
Определения Environment.c:59
void SetAreaGenericColdness()
Determines whether player is in cold area which restricts use of some actions (digging)
Определения Environment.c:669
void ProcessTemperatureSources()
Processes registered UTSources and calculates resulting m_UTSAverageTemperature.
Определения Environment.c:1511
float m_PlayerTemperature
Определения Environment.c:46
bool OverridenHeatComfort(out float value)
void CheckUnderRoof()
Checks whether character is sheltered and sets the information.
Определения Environment.c:391
void AddToEnvironmentTemperature(float pTemperature)
float GetDayOrNight()
Определения Environment.c:1928
float m_ItemTemperatureCoef
Определения Environment.c:64
const float SNOWFALL_LIMIT_LOW
Определения Environment.c:30
float m_EnvironmentTemperature
Определения Environment.c:58
ref array< int > m_HeadParts
Определения Environment.c:81
void ApplyDrynessToItemEx(ItemBase pItem, EnvironmentDrynessData pDrynessData)
Определения Environment.c:875
ref array< int > m_SlotIdsUpper
Определения Environment.c:77
float NormalizedTemperature(float temperature, float lowerLimit=GameConstants.ENVIRO_LOW_TEMP_LIMIT, float upperLimit=GameConstants.ENVIRO_HIGH_TEMP_LIMIT)
Определения Environment.c:1721
bool m_IsTempSet
Определения Environment.c:71
float GetWaterLevel()
Определения Environment.c:1703
float m_PlayerSpeed
Определения Environment.c:45
WorldData m_WorldData
Определения Environment.c:85
void ProcessItemsWetness(array< int > pSlotIds)
Soak items at specific Slot ID(s)
Определения Environment.c:697
float m_HeatSourceTemp
DEPRECATED.
Определения Environment.c:1767
float GetTemperature()
Определения Environment.c:500
float GetWindModifierPerSurface()
Wind intensity (influence) modifier of temperature value.
Определения Environment.c:492
float GetApplicableHeatbuffer()
Определения Environment.c:1205
ref array< int > m_SlotIdsLower
Определения Environment.c:79
void ProcessItemsInHandsTemperature()
Process temperature of item in character hands and cool/warm it to neutral temparature.
Определения Environment.c:1250
void Environment(PlayerBase pPlayer)
Определения Environment.c:106
void SetEnvironmentSnapshotData()
Определения Environment.c:1900
bool IsUnderRoof()
Is character under roof (periodically checked - GameConstants.ENVIRO_TICK_ROOF_RC_CHECK)....
Определения Environment.c:305
ref SimpleMovingAverage< float > m_AverageHeatComfortBuffer
Определения Environment.c:91
bool m_IsUnderRoofBuilding
Определения Environment.c:69
const float WATER_LEVEL_MID
Определения Environment.c:34
float m_Rain
target value of heatcomfort (non-buffered)
Определения Environment.c:52
float m_HeatComfort
Определения Environment.c:48
float m_Snowfall
Определения Environment.c:53
void ProcessWetnessByWaterLevel(float pWaterLevel)
Processes items wetness in player possession based on the current water level (the character is in)
Определения Environment.c:679
int m_LiquidType
Определения Environment.c:61
float WindEffectTemperatureValue(float temperatureInput)
backward compatibility [<1.28]
Определения Environment.c:1918
const float SNOWFALL_WIND_COMBINED_THRESHOLD
Определения Environment.c:31
bool m_IsUnderRoof
Определения Environment.c:68
void SetProcessedItemTemperature(ItemBase item, float heatPermeabilityCoef=1.0)
Определения Environment.c:1315
void CollectAndSetPlayerData()
Sets character related value for furher use.
Определения Environment.c:626
enum EEnvironmentHeatcomfortBehaviorCategory m_ClothingHeatComfort
float m_Wind
Определения Environment.c:54
void ProcessItemHierarchyRecursive(ItemBase item, float heatPermeabilityCoef=1.0)
Определения Environment.c:1264
bool IsTemperatureSet()
For safe-guards, waiting for the proper temperature to be set.
Определения Environment.c:286
float m_PlayerHeat
Определения Environment.c:47
ref array< int > m_BodyParts
Определения Environment.c:82
float m_DayOrNight
Определения Environment.c:56
void SetItemHeatingCoef(float val)
Определения Environment.c:1556
void GatherTemperatureSources()
Checks characters proximity for usable Universal Temperature Sources and register them.
Определения Environment.c:1476
const float WATER_LEVEL_LOW
Определения Environment.c:35
const float WATER_LEVEL_NONE
Определения Environment.c:36
void OnTemperatureSourcesLeft()
Event fired when characters leave the UTSource proximity.
ref array< int > m_FeetParts
Определения Environment.c:83
float m_WetDryTick
Определения Environment.c:38
float EnvTempToCoef(float pTemp)
Определения Environment.c:1344
const float WATER_LEVEL_HIGH
Определения Environment.c:33
EEnvironmentHeatcomfortBehaviorCategory
Categories that are changing behavior of Heat comfort processing.
Определения Environment.c:5
@ CAR_ENGINE_ON
Определения Environment.c:7
ref SimpleMovingAverage< float > m_WindAverageBuffer
Определения Environment.c:1768
string GetDebugMessage()
debug
Определения Environment.c:1663
float GetWetDelta()
Calculates soaking/drying delta based on character's location and weather.
Определения Environment.c:566
string m_SurfaceType
Определения Environment.c:60
bool DetermineHeatcomfortBehavior()
Changes Heat Comfort curve behavior based on where the character is.
Определения Environment.c:369
void ApplyWetnessToItem(ItemBase pItem)
Определения Environment.c:735
void BodyPartHeatProperties(int pBodyPartId, float pCoef, out float pHeatComfort, out float pHeat)
Iterate through given body part and calculates heatcofort and item heat value.
Определения Environment.c:1356
float m_HeatBufferCapPrevious
reused as state toggle
Определения Environment.c:74
bool IsRaining()
Rain phenomenon actual value > RAIN_LIMIT_LOW.
Определения Environment.c:351
void SetEnvironmentTemperature()
Определения Environment.c:660
ref array< int > m_SlotIdsBottom
Определения Environment.c:78
float GetEnvironmentTemperature()
Calculations of temperarute for different situations.
Определения Environment.c:520
float GetUniversalSourcesTemperageAverage()
Определения Environment.c:1571
float NakedBodyPartHeatComfortPenalty(int pBodyPartSlotId, float pCoef)
Calculates penalty value for heatcomfort - this simulates uncovered body part reaction.
Определения Environment.c:1455
void SetHeatcomfortDirectly()
Определения Environment.c:1089
void ProcessItemsHeat()
Определения Environment.c:1779
void ProcessWetnessByRain()
Определения Environment.c:1785
float m_WaterLevel
Определения Environment.c:67
float m_ItemsWetnessMax
Определения Environment.c:39
float m_PlayerHeightPos
Определения Environment.c:44
void OnTemperatureSourcesEnter()
Event fired when characters enters into UTSource proximity.
void ApplyDrynessToItem(ItemBase pItem)
Определения Environment.c:869
bool IsSnowing()
Snowfall phenomenon actual value > SNOWFALL_LIMIT_LOW.
Определения Environment.c:359
float m_RoofCheckTimer
keeps wetness of most wet item in player's possesion
Определения Environment.c:40
class EnvironmentDrynessData RAIN_LIMIT_LOW
Simulates influence of environment to character Takes input data from WorldData, Weather system and e...
void ProcessItemsDryness()
Dry items in player possession.
Определения Environment.c:825
float m_Fog
Определения Environment.c:55
float GetPlayerHeat()
Character's heat (calculated from movement speed multiplied by constant)
Определения Environment.c:295
float m_TargetHeatComfort
player's heatcomfort (buffered, stored in player stats)
Определения Environment.c:13
float m_Clouds
Определения Environment.c:57
float GetTargetHeatComfort()
Определения Environment.c:505
bool m_HasTemperatureSources
Определения Environment.c:87
bool IsUnderRoofBuilding()
Is character under building's roof (periodically checked - GameConstants.ENVIRO_TICK_ROOF_RC_CHECK)....
Определения Environment.c:343
bool IsInsideVehicle()
Определения Environment.c:1933
void ProcessHeatComfort()
Calculates and process player's heatcomfort related to defined body parts.
Определения Environment.c:973
void ProcessHeatBuffer(EnvironmentSnapshotData data)
Определения Environment.c:1105
void ProcessItemsTemperature(array< int > pBodyPartIds)
Iterate through items in player posession (by given body parts) and cool/warm them to neutral tempara...
Определения Environment.c:1219
void CheckWaterContact(out float pWaterLevel)
Checks player's contanct with water.
Определения Environment.c:421
string m_Surface
Определения ImpactEffects.c:17
void PlayerStat(T min, T max, T init, string label, int flags)
Определения PlayerStatBase.c:43
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings
const int windowPosY
Определения PluginPresenceNotifier.c:77
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
void Synch(EntityAI victim)
keeping "step" here for consistency only
Определения TrapBase.c:281
bool m_Initialized
Определения UiHintPanel.c:317
Определения CarScript.c:171
Определения CivilianSedan.c:2
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
represents base for cargo storage for entities
Определения Cargo.c:7
Super root of all classes in Enforce script.
Определения EnScript.c:11
static proto bool RayCastBullet(vector begPos, vector endPos, PhxInteractionLayers layerMask, Object ignoreObj, out Object hitObject, out vector hitPosition, out vector hitNormal, out float hitFraction)
Определения DayZPhysics.c:124
static string EnumToString(typename e, int enumValue)
Return string name of enum value.
Определения EnConvert.c:614
Определения EnConvert.c:603
float m_TemperatureSourceDistance
Определения Environment.c:19
bool m_UseTemperatureSources
Определения Environment.c:18
proto native EntityAI GetAttachmentFromIndex(int index)
proto native CargoBase GetCargo()
cargo
proto native int AttachmentCount()
Returns count of attachments attached to this item.
script counterpart to engine's class Inventory
const float STAGE_THRESHOLDS[NUMBER_OF_STAGES]
Определения HeatBuffer.c:4
Определения HeatBuffer.c:2
Определения CrashBase.c:2
proto native float GetCurrentMovementSpeed()
0,1,2..3 idle, walk, run, sprint
Определения human.c:434
int m_iMovement
current stance (DayZPlayerConstants.STANCEIDX_ERECT, ...), only if the command has a stance
Определения human.c:1157
Определения human.c:1154
proto native EntityAI GetParent()
returns parent of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
provides access to slot configuration
Определения InventorySlots.c:6
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
Определения EnMath.c:7
Определения ObjectTyped.c:2
bool Deserializer(Serializer ctx)
Определения param.c:18
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
Определения PlayerBaseClient.c:2
static const float THRESHOLD_HEAT_COMFORT_MINUS_WARNING
Определения PlayerConstants.c:92
Определения PlayerConstants.c:2
proto bool Write(void value_out)
proto bool Read(void value_in)
Native class for boats - handles physics simulation.
Определения Boat.c:32
proto native Fog GetFog()
Returns a fog phenomenon object.
proto native WindMagnitude GetWindMagnitude()
Returns a wind magnitude phenomenon object.
proto native Snowfall GetSnowfall()
Returns a snowfall phenomenon object.
proto native Rain GetRain()
Returns a rain phenomenon object.
proto native Overcast GetOvercast()
Returns an overcast phenomenon object.
Определения Weather.c:168
proto native float GetActual()
static string ToString(int value)
Определения WorldData.c:471
Определения WorldData.c:464
Keeps information about currently loaded world, like temperature.
Определения WorldData.c:3
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
string ToString()
Определения EnConvert.c:3
proto string ToString(bool simple=true)
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:119
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
eModifiers
Определения eModifiers.c:2
class LOD Object
@ DEFAULT
Определения DebugTextFlags.c:9
const float ENVIRO_HEATISOLATION_VEST_WEIGHT
weight of back for the sum of heat isolation
Определения 3_Game/DayZ/constants.c:1099
const float ENVIRO_HEATISOLATION_BACK_WEIGHT
how much this feet parts (clothing) affects final heatcomfort
Определения 3_Game/DayZ/constants.c:1098
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const float TEMP_COEF_INVENTORY
Определения 3_Game/DayZ/constants.c:946
const float TEMP_COEF_SWIMMING
Определения 3_Game/DayZ/constants.c:953
const float ENVIRO_WIND_CHILL_LIMIT
Affects the slope of calculation.
Определения 3_Game/DayZ/constants.c:798
const float ENVIRO_NAKED_BODY_PENALTY_SNOWFALL_MIN_VALUE
how intensive a rain should be to enable rain penalty on naked body
Определения 3_Game/DayZ/constants.c:791
const float ENVIRO_TEMPERATURE_UNDERROOF_COEF
increases temp inside vehicles
Определения 3_Game/DayZ/constants.c:737
const float ENVIRO_TEMP_EFFECT_ON_PLAYER
comfort temperature of environment for the player
Определения 3_Game/DayZ/constants.c:760
static const float ENVIRO_HEATCOMFORT_VEST_WEIGHT
Определения 3_Game/DayZ/constants.c:746
const float ENVIRO_HIGH_TEMP_LIMIT
lowest temperature(deg Celsius) where the player gets lowest possible heat comfort (-1)
Определения 3_Game/DayZ/constants.c:758
const float ENVIRO_HEATCOMFORT_MAX_STEP_SIZE
when is sun highest on sky
Определения 3_Game/DayZ/constants.c:742
static const float ENVIRO_HEATCOMFORT_HIPS_WEIGHT
Определения 3_Game/DayZ/constants.c:752
const float ENVIRO_FOG_DRY_EFFECT
how many % of ENVIRO_SUN_INCREMENT is reduced by cloudy sky
Определения 3_Game/DayZ/constants.c:731
const float COLD_AREA_TEMPERATURE_THRESHOLD
Определения 3_Game/DayZ/constants.c:794
const float ENVIRO_DRY_INCREMENT
amount of wetness added to items wet value each tick if is raining
Определения 3_Game/DayZ/constants.c:727
const float ENVIRO_ISOLATION_WETFACTOR_DRENCHED
Определения 3_Game/DayZ/constants.c:780
const float ENVIRO_CLOUD_DRY_EFFECT
how much is the generic temp effect increased when player is next to a fireplace
Определения 3_Game/DayZ/constants.c:730
const float ENVIRO_PLAYER_HEATBUFFER_CAPACITY_MIN
How much heat buffer change rates are affected by temperature.
Определения 3_Game/DayZ/constants.c:765
const float ENVIRO_WET_INCREMENT
in secs. how often we should check if player is under the roof (raycast)
Определения 3_Game/DayZ/constants.c:726
const float ENVIRO_PLAYER_HEATBUFFER_WATEREFFECT
impact of enviro temperature on player (lower value = higher, cannot be zero or below!...
Определения 3_Game/DayZ/constants.c:761
const float ENVIRO_STOMACH_WEIGHT
Определения 3_Game/DayZ/constants.c:756
const float ENVIRO_TICKS_TO_WETNESS_CALCULATION
in secs. how often should enviro effet process
Определения 3_Game/DayZ/constants.c:724
static const float ENVIRO_HEATCOMFORT_LEGS_WEIGHT
Определения 3_Game/DayZ/constants.c:750
static const float ENVIRO_HEATCOMFORT_WEIGHT_SUMMARY
don't forget to update the weights from above if you are adding/removing them
Определения 3_Game/DayZ/constants.c:754
const float ENVIRO_PLAYER_HEATBUFFER_DECREASE
impact of water contact on player's heatbuffer
Определения 3_Game/DayZ/constants.c:762
const float ENVIRO_PLAYER_HEATBUFFER_TEMP_AFFECT
How much heat buffer increases per one enviro tick.
Определения 3_Game/DayZ/constants.c:764
static const float ENVIRO_HEATCOMFORT_GLOVES_WEIGHT
Определения 3_Game/DayZ/constants.c:749
static const float ENVIRO_HEATCOMFORT_FEET_WEIGHT
Определения 3_Game/DayZ/constants.c:751
const float ENVIRO_TICK_ROOF_RC_CHECK
each X (ticks) is processed wetness on items on player
Определения 3_Game/DayZ/constants.c:725
const float ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT
Определения 3_Game/DayZ/constants.c:807
const float ENVIRO_TEMPERATURE_INSIDE_VEHICLE_COEF
heat entity generates if not moving
Определения 3_Game/DayZ/constants.c:736
const float ENVIRO_TEMP_SOURCES_LOOKUP_RADIUS
Определения 3_Game/DayZ/constants.c:788
const float ENVIRO_WIND_EFFECT
windchill effect on base temperature
Определения 3_Game/DayZ/constants.c:739
const float ENVIRO_WIND_EFFECT_SLOPE
time modifier, how much longer it takes to dig up worms while in a cold area
Определения 3_Game/DayZ/constants.c:797
const float ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT
damage per second dealt to attachment by fire
Определения 3_Game/DayZ/constants.c:806
const float ENVIRO_TICK_RATE
Определения 3_Game/DayZ/constants.c:723
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:811
static const float ENVIRO_HEATCOMFORT_BODY_WEIGHT
Определения 3_Game/DayZ/constants.c:747
const float ENVIRO_PLAYER_COMFORT_TEMP
highest temperature(deg Celsius) where the player gets highest possible heat comfort (1)
Определения 3_Game/DayZ/constants.c:759
const float ENVIRO_PLAYER_HEATBUFFER_INCREASE
How much heat buffer decreases per one enviro tick.
Определения 3_Game/DayZ/constants.c:763
static const float ENVIRO_HEATCOMFORT_BACK_WEIGHT
Определения 3_Game/DayZ/constants.c:748
static const float ENVIRO_HEATCOMFORT_HEADGEAR_WEIGHT
max step of dynamic heatcomfort change (applies if diff between target and dynamic HC is bigger than ...
Определения 3_Game/DayZ/constants.c:744
const float ENVIRO_DEFAULT_ENTITY_HEAT
how many times slower is wetting/drying items in backpacks
Определения 3_Game/DayZ/constants.c:735
const float ENVIRO_SNOW_WET_COEF
Above this value, the wind effect increases the modified temperature.
Определения 3_Game/DayZ/constants.c:800
const float ENVIRO_NAKED_BODY_PENALTY_RAIN_MIN_VALUE
Определения 3_Game/DayZ/constants.c:790
const float ENVIRO_LOW_TEMP_LIMIT
how much stomach content affects final heatcomfort
Определения 3_Game/DayZ/constants.c:757
static const float ENVIRO_HEATCOMFORT_MASK_WEIGHT
how much this body part affects final heatcomfort
Определения 3_Game/DayZ/constants.c:745
static ref array< ref TFloatArray > ENVIRO_PLAYER_HEATBUFFER_STAGE_RATELIMIT
Minimal heatbuffer capacity of naked character.
Определения 3_Game/DayZ/constants.c:768
const float STATE_DAMP
Определения 3_Game/DayZ/constants.c:878
const float STATE_SOAKING_WET
Определения 3_Game/DayZ/constants.c:876
const float STATE_WET
Определения 3_Game/DayZ/constants.c:877
const int LIQUID_STILLWATER
Определения 3_Game/DayZ/constants.c:555
const int LIQUID_HOTWATER
Определения 3_Game/DayZ/constants.c:556
const int LIQUID_FRESHWATER
Определения 3_Game/DayZ/constants.c:554
const int LIQUID_WATER
Определения 3_Game/DayZ/constants.c:544
const int LIQUID_RIVERWATER
Определения 3_Game/DayZ/constants.c:545
const int LIQUID_SALTWATER
Определения 3_Game/DayZ/constants.c:553
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float SqrFloat(float f)
Returns squared value.
static proto float Round(float f)
Returns mathematical round of value.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static float Remap(float inputMin, float inputMax, float outputMin, float outputMax, float inputValue, bool clampedOutput=true)
Returns given value remaped from input range into output range.
Определения EnMath.c:740
static proto float AbsFloat(float f)
Returns absolute value.
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
proto native volatile void Update()
Определения PlayerSoundManager.c:125