DayZ 1.24
Loading...
Searching...
No Matches
Environment.c
Go to the documentation of this file.
2{
3 const float RAIN_LIMIT_LOW = 0.05;
4
5 const float WATER_LEVEL_HIGH = 1.5;
6 const float WATER_LEVEL_MID = 1.2;
7 const float WATER_LEVEL_LOW = 0.5;
8 const float WATER_LEVEL_NONE = 0.15;
9
10 protected float m_WetDryTick; //ticks passed since last clothing wetting or drying
11 protected float m_ItemsWetnessMax;
12 protected float m_RoofCheckTimer; // keeps info about tick time
13
14 //player
16 protected float m_PlayerHeightPos; // y position of player above water level (meters)
17 protected float m_PlayerSpeed; // 1-3 speed of player movement
18 protected float m_PlayerTemperature; //34-44
19 protected float m_PlayerHeat; //3-9 heatcomfort generated by entites movement
20 protected float m_HeatComfort; //delta that changes entitys temperature
21
22 //environment
23 protected float m_Rain = 0; // 0-1 amount of rain
24 protected float m_Wind = 0; // strength of wind
25 protected float m_Fog = 0; // 0-1 how foggy it is
26 protected float m_DayOrNight = 0; // 0-1 day(1) or night(0)
27 protected float m_Clouds = 0; // 0-1 how cloudy it is
28 protected float m_EnvironmentTemperature = 0; //temperature of environment player is in
29 protected float m_Time = 0;
30 protected string m_SurfaceType;
31
32 //
33 protected float m_WaterLevel;
34 protected bool m_IsUnderRoof;
36 protected bool m_IsInWater;
37 protected bool m_IsTempSet;
38 //
39 protected float m_HeatSourceTemp;
40 protected float m_HeatBufferTimer;
41
46
50
52
54 protected float m_UTSAverageTemperature;
57
58#ifdef DIAG_DEVELOPER
59 bool m_Debug = false;
60
61 bool m_DebugLogDryWet = false;
62#endif
63
68
70 {
72 m_PlayerSpeed = 0.0;
73 m_WetDryTick = 0.0;
74 m_RoofCheckTimer = 0.0;
75 m_WaterLevel = 0.0;
76 m_HeatComfort = 0.0;
77
78 m_IsUnderRoof = false;
79 m_IsInWater = false;
80 m_SurfaceType = "cp_dirt";
81
83
85
89
93 InventorySlots.HEADGEAR,
94 InventorySlots.MASK,
95 InventorySlots.EYEWEAR,
96 InventorySlots.GLOVES,
97 InventorySlots.ARMBAND,
98 InventorySlots.BODY,
99 InventorySlots.HIPS,
100 InventorySlots.VEST,
101 InventorySlots.BACK,
102 InventorySlots.LEGS,
103 InventorySlots.FEET
104 };
108 InventorySlots.GLOVES,
109 InventorySlots.ARMBAND,
110 InventorySlots.BODY,
111 InventorySlots.HIPS,
112 InventorySlots.VEST,
113 InventorySlots.BACK,
114 InventorySlots.LEGS,
115 InventorySlots.FEET
116 };
120 InventorySlots.HIPS,
121 InventorySlots.LEGS,
122 InventorySlots.FEET
123 };
127 InventorySlots.FEET,
128 };
129
133 m_HeadParts = {
134 InventorySlots.HEADGEAR,
135 InventorySlots.MASK,
136 };
137
139 m_BodyParts = {
140 InventorySlots.GLOVES,
141
142 InventorySlots.BODY,
143 InventorySlots.BACK,
144 InventorySlots.VEST,
145 };
146
148 m_FeetParts = {
149 InventorySlots.LEGS,
150 InventorySlots.FEET,
151 };
152 }
153
154
155 // Calculates heatisolation of clothing, process its wetness, collects heat from heated items and calculates player's heat comfort
156 void Update(float pDelta)
157 {
158 if (m_Player)
159 {
163 {
164 if (!IsInsideBuilding())
166
168 }
169
170 m_Time += pDelta;
172 {
173 m_Time = 0;
174 m_WetDryTick++; // Sets whether it is time to add wetness to items and clothing
175
181
183
186
189 {
190 if (IsWaterContact())
192 else if (IsRaining() && !IsInsideBuilding() && !IsUnderRoof() && !IsInsideVehicle())
194 else
196
198 if ((m_ItemsWetnessMax < GameConstants.STATE_WET) && (m_Player.GetStatWet().Get() == 1))
199 m_Player.GetStatWet().Set(0);
200 else if ((m_ItemsWetnessMax >= GameConstants.STATE_WET) && (m_Player.GetStatWet().Get() == 0))
201 m_Player.GetStatWet().Set(1);
202
203 m_WetDryTick = 0;
205 }
206 }
207 }
208 }
209
211 {
212 return m_IsTempSet;
213 }
214
215 // DEPRECATED
217
224
226 {
227 return m_IsUnderRoof;
228 }
229
230 protected bool IsWaterContact()
231 {
232 return m_IsInWater;
233 }
234
236 {
237 return m_Player && m_Player.IsSoundInsideBuilding();
238 }
239
240 protected bool IsInsideVehicle()
241 {
242 return m_Player && m_Player.IsInVehicle();
243 }
244
245 private bool IsUnderRoofBuilding()
246 {
248 }
249
250 protected bool IsRaining()
251 {
252 return m_Rain > RAIN_LIMIT_LOW;
253 }
254
256 protected void CheckUnderRoof()
257 {
258 // if inside vehicle return immediatelly
259 if (IsInsideVehicle())
260 {
261 m_IsUnderRoof = false;
262 m_IsUnderRoofBuilding = false;
263 return;
264 }
265
266 float hitFraction;
268 vector from = m_Player.GetPosition();
269 vector to = from + "0 25 0";
272
274
276 }
277
278 protected void CheckWaterContact(out float pWaterLevel)
279 {
280 m_IsInWater = false;
281 if (m_Player.IsSwimming())
282 {
283 m_IsInWater = true;
285 m_Player.GetMovementState(hms);
287 if (hms.m_iMovement >= DayZPlayerConstants.MOVEMENTIDX_WALK)
289
290 return;
291 }
292
295 {
296 m_IsInWater = false;
297 return;
298 }
299
300 string surfType;
301 int liquidType;
302
303 g_Game.SurfaceUnderObject(m_Player, surfType, liquidType);
304
305 switch (liquidType)
306 {
307 case 0: // sea
308 case LIQUID_WATER:
310 pWaterLevel = m_Player.GetCurrentWaterLevel();
311 m_IsInWater = true;
312 break;
313 }
314
316 m_Player.SetInWater(m_IsInWater);
317
320 }
321
322 // ENVIRONMENT
323 // Returns amount of deg C air temperature should be lowered by, based on player's height above water level
329
331 {
333 return 0.0;
334
335 return g_Game.ConfigGetFloat("CfgSurfaces " + m_SurfaceType + " windModifier");
336 }
337
339 {
341 }
342
343 // Calculates and return temperature of environment
375
376 // Calculats wet/drying delta based on player's location and weather
413
414 // EXPOSURE
415 // Each tick updates current entity member variables
416 protected void CollectAndSetPlayerData()
417 {
418 vector playerPos = m_Player.GetPosition();
420
421 HumanCommandMove hcm = m_Player.GetCommand_Move();
422 if (hcm)
423 m_PlayerSpeed = hcm.GetCurrentMovementSpeed();
424
426 }
427
428 // Each tick updates current environment member variables
430 {
431 Weather weather = g_Game.GetWeather();
432 m_Rain = weather.GetRain().GetActual();
433 m_DayOrNight = g_Game.GetWorld().GetSunOrMoon();
434 m_Fog = weather.GetFog().GetActual();
435 m_Clouds = weather.GetOvercast().GetActual();
436 m_Wind = m_WindAverageBuffer.Add(weather.GetWindSpeed() / weather.GetWindMaximumSpeed());
437
439 }
440
446
451
453 {
454 // process attachments by water depth
456 {
459 }
461 {
464 }
466 {
469 }
471 {
474 }
475 }
476
477 // Wets or dry items once in given time
479 {
481
482 int playerAttachmentCount = m_Player.GetInventory().AttachmentCount();
483
484 LogDryWetProcess(string.Format("Environment :: ProcessItemsWetness (update interval=%1s)", GameConstants.ENVIRO_TICK_RATE));
485 for (int attIdx = 0; attIdx < playerAttachmentCount; ++attIdx)
486 {
487 attachment = m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
488 if (attachment.IsItemBase())
489 {
490 int attachmentSlotsCount = attachment.GetInventory().GetSlotIdCount();
492 {
493 int attachmentSlot = attachment.GetInventory().GetSlotId(attachmentSlotId);
494 for (int i = 0; i < pSlotIds.Count(); ++i)
495 {
496 if (attachmentSlot == pSlotIds.Get(i))
497 {
499 break;
500 }
501 }
502 }
503 }
504 }
505
506 if (m_Player.GetItemInHands())
507 ApplyWetnessToItem(m_Player.GetItemInHands());
508
509 LogDryWetProcess("==========");
510
511 }
512
513 protected void ProcessItemsDryness()
514 {
517
518 int attCount = m_Player.GetInventory().AttachmentCount();
519
520 LogDryWetProcess(string.Format("Environment :: ProcessItemsDryness (update interval=%1s)", GameConstants.ENVIRO_TICK_RATE));
522 drynessData.m_UseTemperatureSources = m_HasTemperatureSources;
523
525 {
527 distance = Math.Max(distance, 0.1);
528 drynessData.m_TemperatureSourceDistance = distance;
529 LogDryWetProcess(string.Format("distance to heatsource: %1 m", distance));
530 }
531
532 for (int attIdx = 0; attIdx < attCount; attIdx++)
533 {
534 attachment = m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
535 if (attachment && attachment.IsItemBase())
536 {
537 item = ItemBase.Cast(attachment);
538 if (item)
540 }
541 }
542
543 if (m_Player.GetItemInHands())
544 ApplyDrynessToItemEx(m_Player.GetItemInHands(), drynessData);
545
546 LogDryWetProcess("==========");
547 }
548
550 {
551 if (pItem)
552 {
554 bool isParentWet = false;
555 bool parentContainsLiquid = false;
557
558 if (pItem.GetInventory().GetCurrentInventoryLocation(iLoc))
559 {
560 EntityAI parent = iLoc.GetParent();
561 if (parent)
562 {
563 parentItem = ItemBase.Cast(parent);
564 if (parentItem)
565 {
567 isParentWet = true;
568
569 if ((parentItem.GetLiquidType() != 0) && (parentItem.GetQuantity() > 0))
571 }
572 else
573 isParentWet = true;
574
575 if ((pItem.GetWet() > m_ItemsWetnessMax) && (parent == m_Player))
576 m_ItemsWetnessMax = pItem.GetWet();
577 }
578 }
579
581 {
582 float soakingCoef = 0;
584 {
585 soakingCoef = pItem.GetSoakingIncrement("parentWithLiquid");
586 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);
587 }
588 else if (isParentWet && parentItem)
589 {
590 if (pItem.GetWet() < parentItem.GetWet())
591 {
592 soakingCoef = pItem.GetSoakingIncrement("wetParent");
593 LogDryWetProcess(string.Format("%1 (soak coef=%2/s, current wetness=%3) [parent wet]", pItem.GetDisplayName(), soakingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
594 }
595 }
596 else
597 {
599 LogDryWetProcess(string.Format("%1 (soak coef=%2/s, current wetness=%3) [normal]", pItem.GetDisplayName(), soakingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
600 }
601
602 pItem.AddWet(soakingCoef);
603 pItem.AddTemperature(GameConstants.ENVIRO_TICK_RATE * GameConstants.TEMPERATURE_RATE_COOLING_PLAYER * pItem.GetSoakingIncrement("wetParent"));
604
605 if (pItem.GetInventory().GetCargo())
606 {
607 int inItemCount = pItem.GetInventory().GetCargo().GetItemCount();
608 for (int i = 0; i < inItemCount; i++)
609 {
611 if (Class.CastTo(inItem, pItem.GetInventory().GetCargo().GetItem(i)))
613 }
614 }
615
616 int attCount = pItem.GetInventory().AttachmentCount();
617 if (attCount > 0)
618 {
619 for (int attIdx = 0; attIdx < attCount; attIdx++)
620 {
621 EntityAI attachment = pItem.GetInventory().GetAttachmentFromIndex(attIdx);
623 if (itemAtt)
625 }
626 }
627 }
628 }
629 }
630
636
638 {
639 if (pItem)
640 {
641 float dryingIncrement = pItem.GetDryingIncrement("player");
642 if (pDrynessData.m_UseTemperatureSources)
643 dryingIncrement = pItem.GetDryingIncrement("playerHeatSource");
644
646 bool isParentWet = false;
647 bool parentContainsLiquid = false;
648
650 if (pItem.GetInventory().GetCurrentInventoryLocation(iLoc))
651 {
652 EntityAI parent = iLoc.GetParent();
653 if (parent)
654 {
655 parentItem = ItemBase.Cast(parent);
656 if (parentItem)
657 {
659 isParentWet = true;
660
661 if ((parentItem.GetLiquidType() != 0) && (parentItem.GetQuantity() > 0))
663 }
664
665 if ((pItem.GetWet() > m_ItemsWetnessMax) && (parent == m_Player))
666 m_ItemsWetnessMax = pItem.GetWet();
667 }
668 }
669
670 float dryingCoef = 0;
671
673 {
674
675 dryingCoef = (-1 * GameConstants.ENVIRO_TICK_RATE * dryingIncrement) / pDrynessData.m_TemperatureSourceDistance;
676 if (pItem.GetWet() >= GameConstants.STATE_DAMP)
677 {
678 LogDryWetProcess(string.Format("%1 (dry coef=%2/s, current wetness=%3) [normal]", pItem.GetDisplayName(), dryingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
679 pItem.AddWet(dryingCoef);
680 }
681
682 if (pItem.GetInventory().GetCargo())
683 {
684 int inItemCount = pItem.GetInventory().GetCargo().GetItemCount();
685 for (int i = 0; i < inItemCount; i++)
686 {
688 if (Class.CastTo(inItem, pItem.GetInventory().GetCargo().GetItem(i)))
690 }
691 }
692
693 int attCount = pItem.GetInventory().AttachmentCount();
694 if (attCount > 0)
695 {
696 for (int attIdx = 0; attIdx < attCount; attIdx++)
697 {
698 EntityAI attachment = pItem.GetInventory().GetAttachmentFromIndex(attIdx);
700 if (ItemBase.CastTo(itemAtt, attachment))
702 }
703 }
704
706 }
707
709 {
711 dryingCoef = (GameConstants.ENVIRO_TICK_RATE * pItem.GetSoakingIncrement("parentWithLiquid")) / pDrynessData.m_TemperatureSourceDistance;
712 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);
713 pItem.AddWet(dryingCoef);
715 }
716
717 if (isParentWet)
718 {
719 if (pItem.GetWet() < parentItem.GetWet())
720 {
722 dryingCoef = (GameConstants.ENVIRO_TICK_RATE * pItem.GetSoakingIncrement("wetParent")) / pDrynessData.m_TemperatureSourceDistance;
723 LogDryWetProcess(string.Format("%1 (dry coef=%2/s, current wetness=%3) [parent wet]", pItem.GetDisplayName(), dryingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
724 pItem.AddWet(dryingCoef);
725 }
726
728 }
729 }
730 }
731
732 // HEAT COMFORT
734 protected void ProcessItemsHeat()
735 {
736 float hcHead, hcBody, hcFeet;
737 float hHead, hBody, hFeet;
738
739 float heatComfortAvg;
740 float heatAvg;
741
745
747 heatAvg = (hHead + hBody + hFeet) / 3;
749
750 // heat buffer
751 float applicableHB = 0.0;
752 if (m_UTSAverageTemperature < 0.001)
753 {
754 applicableHB = m_Player.GetStatHeatBuffer().Get() / 30.0;
755 if (applicableHB > 0.0)
756 {
757 if (m_HeatBufferTimer > 1.0)
759 else
761 }
762 else
763 m_HeatBufferTimer = 0.0;
764 }
765 else
766 {
767 applicableHB = m_Player.GetStatHeatBuffer().Get() / 30.0;
769 {
771 m_HeatBufferTimer = 0.0;
772 }
773 else
774 m_HeatBufferTimer = 0.0;
775 }
776
780 else
781 {
784 }
785
786 m_HeatComfort = Math.Clamp(m_HeatComfort, m_Player.GetStatHeatComfort().GetMin(), m_Player.GetStatHeatComfort().GetMax());
787
788 m_Player.GetStatHeatComfort().Set(m_HeatComfort);
789 }
790
792 protected bool OverridenHeatComfort(out float value);
793
794 protected float EnvTempToCoef(float pTemp)
795 {
797 return 1;
798
800 return -1;
801
803 }
804
807 {
808 int attCount;
809
812
813 pHeatComfort = -1;
814 attCount = m_Player.GetInventory().AttachmentCount();
815
816 for (int attIdx = 0; attIdx < attCount; attIdx++)
817 {
818 attachment = m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
819 if (attachment.IsClothing())
820 {
821 item = ItemBase.Cast(attachment);
822 int attachmentSlot = attachment.GetInventory().GetSlotId(0);
823
825 for (int i = 0; i < pBodyPartIds.Count(); i++)
826 {
827 if (attachmentSlot == pBodyPartIds.Get(i))
828 {
829 float heatIsoMult = 1.0;
830 if (attachmentSlot == InventorySlots.VEST)
832
833 if (attachmentSlot == InventorySlots.BACK)
835
836 pHeatComfort += heatIsoMult * MiscGameplayFunctions.GetCurrentItemHeatIsolation(item);
837
838 // go through any attachments and cargo (only current level, ignore nested containers - they isolate)
839 int inAttCount = item.GetInventory().AttachmentCount();
840 if (inAttCount > 0)
841 {
842 for (int inAttIdx = 0; inAttIdx < inAttCount; inAttIdx++)
843 {
844 EntityAI inAttachment = item.GetInventory().GetAttachmentFromIndex(inAttIdx);
846 if (itemAtt)
847 pHeat += itemAtt.GetTemperature();
848 }
849 }
850 if (item.GetInventory().GetCargo())
851 {
852 int inItemCount = item.GetInventory().GetCargo().GetItemCount();
853
854 for (int j = 0; j < inItemCount; j++)
855 {
857 if (Class.CastTo(inItem, item.GetInventory().GetCargo().GetItem(j)))
858 pHeat += inItem.GetTemperature();
859 }
860 }
861 }
862 }
863 }
864 }
865
867 pHeat = (pHeat / pBodyPartIds.Count()) * pCoef;
868 }
869
871 {
872 m_UTemperatureSources.Clear();
873
876
878 {
880 if (ent && ent.IsUniversalTemperatureSource() && ent != m_Player)
881 {
883 if (vector.DistanceSq(m_Player.GetPosition(), ent.GetPosition()) > Math.SqrFloat(ent.GetUniversalTemperatureSource().GetMaxRange()))
884 continue;
885
886 m_UTemperatureSources.Insert(ent.GetUniversalTemperatureSource());
887 }
888 }
889
890 if (m_Player.GetItemInHands() && m_Player.GetItemInHands().IsUniversalTemperatureSource())
891 m_UTemperatureSources.Insert(m_Player.GetItemInHands().GetUniversalTemperatureSource());
892 }
893
895 {
896 if (m_UTemperatureSources.Count() == 0)
897 {
900 return;
901 }
902
904
905 // get temperature from the source (based on distance), save it for min/max filtering
908
909 float min = MiscGameplayFunctions.GetMinValue(utsTemperatures);
910 float max = MiscGameplayFunctions.GetMaxValue(utsTemperatures);
911
912 if (max > 0 && min < 0)
913 {
916 }
917 else
919
921 }
922
927
929 {
930 float distance = vector.Distance(m_Player.GetPosition(), uts.GetPosition());
931 distance = Math.Max(distance, 0.1); //min distance cannot be 0 (division by zero)
932 float temperature = 0;
933
934 //Debug.Log(string.Format("CalcTemperatureFromTemperatureSource::distance: %1", distance), "Environment");
935
937 if (distance > uts.GetFullRange())
938 {
939 float distFactor = 1 - (distance / uts.GetMaxRange());
940 distFactor = Math.Max(distFactor, 0.0);
941 temperature = uts.GetTemperature() * distFactor;
942 //temperature = Math.Clamp(temperature, uts.GetTemperatureMin(), uts.GetTemperatureMax());
943 //Debug.Log(string.Format("CalcTemperatureFromTemperatureSource::distFactor: %1", distFactor), "Environment");
944 //Debug.Log(string.Format("CalcTemperatureFromTemperatureSource::temperatureXX: %1", temperature), "Environment");
945 }
946 else
947 temperature = uts.GetTemperature();
948
949 //Debug.Log(string.Format("CalcTemperatureFromTemperatureSource::temperature: %1", temperature), "Environment");
950
951 return temperature;
952 }
953
955#ifdef DIAG_DEVELOPER
957 {
959 data.Synch(this, m_Player);
960 return data;
961 }
962
964 {
967 }
968
970 {
971 int windowPosX = 10;
972 int windowPosY = 200;
973
974 Object obj;
975
976 DbgUI.Begin("Player stats", windowPosX, windowPosY);
977 if (enabled)
978 {
979 DbgUI.Text(string.Format("Heat comfort: %1", data.m_PlayerData.m_HeatComfort));
980 DbgUI.Text(string.Format("Inside: %1 (%2)", data.m_PlayerData.m_Inside, data.m_PlayerData.m_Surface));
981 DbgUI.Text(string.Format("Under roof: %1 (%2)", data.m_PlayerData.m_UnderRoof, data.m_PlayerData.m_UnderRoofTimer));
982 if (data.m_PlayerData.m_WaterLevel > 0)
983 DbgUI.Text(string.Format("Water Level: %1", data.m_PlayerData.m_WaterLevel));
984
985 }
986 DbgUI.End();
987
988 DbgUI.Begin("Weather stats:", windowPosX, windowPosY + 200);
989 if (enabled)
990 {
991 DbgUI.Text(string.Format("Env temperature (base): %1", data.m_MiscData.m_TemperatureBase));
992 DbgUI.Text(string.Format("Env temperature (modfied): %1", data.m_MiscData.m_TemperatureModified));
993 DbgUI.Text(string.Format("Wind: %1 (x%2)", data.m_WeatherData.m_Wind, data.m_WeatherData.m_WindModifier));
994 DbgUI.Text(string.Format("Rain: %1", data.m_WeatherData.m_Rain));
995 DbgUI.Text(string.Format("Day/Night (1/0): %1", data.m_MiscData.m_DayOrNight));
996 DbgUI.Text(string.Format("Fog: %1", data.m_WeatherData.m_Fog));
997 DbgUI.Text(string.Format("Clouds: %1", data.m_WeatherData.m_Clouds));
998 DbgUI.Text(string.Format("Height: %1", data.m_MiscData.m_Height));
999 DbgUI.Text(string.Format("Wet delta: %1", data.m_MiscData.m_WetDelta));
1000 }
1001 DbgUI.End();
1002 }
1003
1005 {
1006 data.m_Wind = m_Wind;
1007 data.m_WindModifier = GetWindModifierPerSurface();
1008 data.m_Rain = m_Rain;
1009 data.m_Fog = m_Fog;
1010 data.m_Clouds = m_Clouds;
1011 }
1012#endif
1013
1015 {
1016 string message;
1017 message += "Player stats";
1018 message += "\nHeat comfort: " + m_HeatComfort.ToString();
1019 message += "\nInside: " + IsInsideBuilding().ToString() + " (" + m_Player.GetSurfaceType() + ")";
1020 message += "\nUnder roof: " + m_IsUnderRoof.ToString() + " (" + GetNextRoofCheck() + ")";
1022 message += "\nWater Level: " + m_WaterLevel;
1023
1024 message += "\n\nWeather stats";
1025 message += "\nEnv temperature (base): " + g_Game.GetMission().GetWorldData().GetBaseEnvTemperature().ToString();
1026 message += "\nEnv temperature (modified): " + m_EnvironmentTemperature.ToString();
1027 message += "\nWind: " + m_Wind.ToString() + " (x" + GetWindModifierPerSurface() + ")";
1028 message += "\nRain: " + m_Rain.ToString();
1029 message += "\nDay/Night (1/0): " + m_DayOrNight.ToString();
1030 message += "\nFog: " + m_Fog.ToString();
1031 message += "\nClouds: " + m_Clouds.ToString();
1032 message += "\nHeight: " + GetTemperatureHeightCorrection().ToString();
1033 message += "\nWet delta: " + GetWetDelta().ToString();
1034
1035 return message;
1036 }
1037
1042
1044 {
1046 return m_WaterLevel;
1047 else
1048 return 0;
1049 }
1050
1052 {
1053 return m_DayOrNight;
1054 }
1055
1056 private void LogDryWetProcess(string message, bool indented = false)
1057 {
1058#ifdef DIAG_DEVELOPER
1059 if (m_DebugLogDryWet)
1060 {
1061 string indentation = "";
1062 if (indented)
1063 indentation = "|--";
1064
1065 Debug.Log(string.Format("%1 %2", indentation, message));
1066 }
1067#endif
1068 }
1069}
1070
1072{
1075}
1076
1077#ifdef DIAG_DEVELOPER
1079{
1080 float m_HeatComfort;
1081 bool m_Inside;
1082 string m_Surface;
1083 bool m_UnderRoof;
1084 int m_UnderRoofTimer;
1085 float m_WaterLevel;
1086
1088 {
1089 m_HeatComfort = player.GetStatHeatComfort().Get();
1090 m_Inside = env.IsInsideBuilding();
1091 m_Surface = player.GetSurfaceType();
1092 m_UnderRoof = env.IsUnderRoof();
1093 m_UnderRoofTimer = env.GetNextRoofCheck();
1094 m_WaterLevel = env.GetWaterLevel();
1095 }
1096
1097 override bool Serialize(Serializer ctx)
1098 {
1099 return (
1100 ctx.Write(m_HeatComfort) && ctx.Write(m_Inside) && ctx.Write(m_Surface) && ctx.Write(m_UnderRoof) && ctx.Write(m_UnderRoofTimer) && ctx.Write(m_WaterLevel));
1101 }
1102
1103 override bool Deserializer(Serializer ctx)
1104 {
1105 return ctx.Read(m_HeatComfort) && ctx.Read(m_Inside) && ctx.Read(m_Surface) && ctx.Read(m_UnderRoof) && ctx.Read(m_UnderRoofTimer) && ctx.Read(m_WaterLevel);
1106 }
1107}
1108
1109class EnvDebugMiscData : Param
1110{
1111 float m_TemperatureBase;
1113 float m_DayOrNight;
1114 float m_Height;
1115 float m_WetDelta;
1116
1117 void Synch(Environment env)
1118 {
1119 m_TemperatureBase = g_Game.GetMission().GetWorldData().GetBaseEnvTemperature();
1120 m_TemperatureModified = env.GetTemperature();
1121 m_DayOrNight = env.GetDayOrNight();
1122 m_Height = env.GetTemperatureHeightCorrection();
1123 m_WetDelta = env.GetWetDelta();
1124 }
1125
1126 override bool Serialize(Serializer ctx)
1127 {
1128 return ctx.Write(m_TemperatureBase) && ctx.Write(m_TemperatureModified) && ctx.Write(m_DayOrNight) && ctx.Write(m_Height) && ctx.Write(m_WetDelta);
1129 }
1130
1131 override bool Deserializer(Serializer ctx)
1132 {
1133 return ctx.Read(m_TemperatureBase) && ctx.Read(m_TemperatureModified) && ctx.Read(m_DayOrNight) && ctx.Read(m_Height) && ctx.Read(m_WetDelta);
1134 }
1135}
1136
1138{
1139 float m_Wind;
1140 float m_WindModifier;
1141 float m_Rain;
1142 float m_Fog;
1143 float m_Clouds;
1144
1145 void Synch(Environment env)
1146 {
1147 env.FillDebugWeatherData(this);
1148 }
1149
1150 override bool Serialize(Serializer ctx)
1151 {
1152 return ctx.Write(m_Wind) && ctx.Write(m_WindModifier) && ctx.Write(m_Rain) && ctx.Write(m_Fog) && ctx.Write(m_Clouds);
1153 }
1154
1155 override bool Deserializer(Serializer ctx)
1156 {
1157 return ctx.Read(m_Wind) && ctx.Read(m_WindModifier) && ctx.Read(m_Rain) && ctx.Read(m_Fog) && ctx.Read(m_Clouds);
1158 }
1159}
1160
1161class EnvDebugData : Param
1162{
1166
1168 {
1169 m_PlayerData.Synch(env, player);
1170 m_MiscData.Synch(env);
1171 m_WeatherData.Synch(env);
1172 }
1173
1174 override bool Serialize(Serializer ctx)
1175 {
1176 return m_PlayerData.Serialize(ctx) && m_MiscData.Serialize(ctx) && m_WeatherData.Serialize(ctx);
1177 }
1178
1179 override bool Deserializer(Serializer ctx)
1180 {
1181 return m_PlayerData.Deserializer(ctx) && m_MiscData.Deserializer(ctx) && m_WeatherData.Deserializer(ctx);
1182 }
1183}
1184#endif
void Serialize()
Definition Inventory.c:193
DayZGame g_Game
Definition DayZGame.c:3528
override Widget Init()
Definition DayZGame.c:120
PhxInteractionLayers
Definition DayZPhysics.c:2
float m_TemperatureSourceDistance
class Environment m_UseTemperatureSources
string m_Surface
static int m_Height
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings
const int windowPosY
void Synch(EntityAI victim)
keeping "step" here for consistency only
Definition TrapBase.c:280
class JsonUndergroundAreaTriggerData GetPosition
Super root of all classes in Enforce script.
Definition 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)
Definition DbgUI.c:60
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
void ProcessItemsWetness(array< int > pSlotIds)
float m_Clouds
Definition Environment.c:27
void CollectAndSetEnvironmentData()
ref SimpleMovingAverage< float > m_WindAverageBuffer
Definition Environment.c:51
float GetPlayerHeat()
Returns heat player generated based on player's movement speed (for now)
void ApplyDrynessToItemEx(ItemBase pItem, EnvironmentDrynessData pDrynessData)
ref array< int > m_SlotIdsBottom
Definition Environment.c:44
float m_RoofCheckTimer
keeps wetness of most wet item in player's possesion
Definition Environment.c:12
float GetWaterLevel()
ref array< int > m_SlotIdsComplete
Definition Environment.c:42
float m_PlayerTemperature
Definition Environment.c:18
const float RAIN_LIMIT_LOW
Definition Environment.c:3
ref array< int > m_SlotIdsLower
Definition Environment.c:45
void CollectAndSetPlayerData()
void CheckWaterContact(out float pWaterLevel)
float GetUniversalSourcesTemperageAverage()
void Init(PlayerBase pPlayer)
Definition Environment.c:69
ref SimpleMovingAverage< float > m_UTSAverageTemperatureBuffer
Definition Environment.c:56
ref array< int > m_SlotIdsUpper
Definition Environment.c:43
const float WATER_LEVEL_HIGH
Definition Environment.c:5
bool m_IsTempSet
Definition Environment.c:37
float GetDayOrNight()
void ProcessItemsHeat()
Calculates and process temperature of items.
bool IsWaterContact()
void ProcessWetnessByWaterLevel(float pWaterLevel)
ref array< UTemperatureSource > m_UTemperatureSources
Definition Environment.c:55
float m_WetDryTick
Definition Environment.c:10
float m_DayOrNight
Definition Environment.c:26
ref array< int > m_BodyParts
Definition Environment.c:48
float m_EnvironmentTemperature
Definition Environment.c:28
bool m_HasTemperatureSources
Definition Environment.c:53
void AddToEnvironmentTemperature(float pTemperature)
string m_SurfaceType
Definition Environment.c:30
void ProcessTemperatureSources()
float EnvTempToCoef(float pTemp)
float m_UTSAverageTemperature
Definition Environment.c:54
void ApplyDrynessToItem(ItemBase pItem)
float GetEnvironmentTemperature()
float m_PlayerHeat
Definition Environment.c:19
float m_WaterLevel
Definition Environment.c:33
bool IsTemperatureSet()
float GetTemperature()
void Environment(PlayerBase pPlayer)
Definition Environment.c:64
void CheckUnderRoof()
Checks whether Player is sheltered.
bool IsInsideVehicle()
float GetTemperatureHeightCorrection()
bool IsRaining()
bool IsUnderRoofBuilding()
void ProcessWetnessByRain()
ref array< int > m_FeetParts
Definition Environment.c:49
const float WATER_LEVEL_NONE
Definition Environment.c:8
float GetWetDelta()
void Update(float pDelta)
const float WATER_LEVEL_MID
Definition Environment.c:6
void GatherTemperatureSources()
PlayerBase m_Player
Definition Environment.c:15
void ProcessItemsDryness()
bool m_IsUnderRoofBuilding
Definition Environment.c:35
bool OverridenHeatComfort(out float value)
DEPRECATED.
void ApplyWetnessToItem(ItemBase pItem)
float m_HeatBufferTimer
DEPRECATED.
Definition Environment.c:40
bool IsUnderRoof()
void BodyPartHeatProperties(array< int > pBodyPartIds, float pCoef, out float pHeatComfort, out float pHeat)
returns weighted avg heat comfort for bodypart
float GetWindModifierPerSurface()
float m_HeatComfort
Definition Environment.c:20
float m_PlayerSpeed
Definition Environment.c:17
float CalcTemperatureFromTemperatureSource(notnull UTemperatureSource uts)
ref array< int > m_HeadParts
Definition Environment.c:47
string GetDebugMessage()
debug
int GetNextRoofCheck()
bool m_IsUnderRoof
Definition Environment.c:34
bool m_IsInWater
Definition Environment.c:36
const float WATER_LEVEL_LOW
Definition Environment.c:7
bool IsInsideBuilding()
float m_ItemsWetnessMax
Definition Environment.c:11
float m_PlayerHeightPos
Definition Environment.c:16
void LogDryWetProcess(string message, bool indented=false)
float m_HeatSourceTemp
Definition Environment.c:39
void SetEnvironmentTemperature()
InventoryLocation.
provides access to slot configuration
Definition EnMath.c:7
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
static const float THRESHOLD_HEAT_COMFORT_MINUS_WARNING
static const float THRESHOLD_HEAT_COMFORT_PLUS_WARNING
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
string ToString()
Definition EnConvert.c:3
proto string ToString()
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.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto native void End()
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto native void Text(string label)
const float TEMPERATURE_RATE_COOLING_PLAYER
Definition constants.c:811
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const float ENVIRO_TEMPERATURE_HEIGHT_REDUCTION
heat entity generates if not moving
Definition constants.c:687
const float ENVIRO_TEMPERATURE_UNDERROOF_COEF
increases temp inside vehicles
Definition constants.c:690
const float ENVIRO_TEMP_EFFECT_ON_PLAYER
comfort temperature of environment for the player
Definition constants.c:703
const float ENVIRO_HIGH_TEMP_LIMIT
lowest temperature(deg Celsius) where the player gets lowest possible heat comfort (-1)
Definition constants.c:701
const float ENVIRO_FOG_DRY_EFFECT
how many % of ENVIRO_SUN_INCREMENT is reduced by cloudy sky
Definition constants.c:679
const float ENVIRO_DRY_INCREMENT
amount of wetness added to items wet value each tick if is raining
Definition constants.c:675
const float ENVIRO_WATER_TEMPERATURE_COEF
converts temperature of items to entities heatcomfort gain
Definition constants.c:685
const float ENVIRO_CLOUD_DRY_EFFECT
how much is the generic temp effect increased when player is next to a fireplace
Definition constants.c:678
const float ENVIRO_WET_INCREMENT
in secs. how often we should check if player is under the roof (raycast)
Definition constants.c:674
const float ENVIRO_CLOUDS_TEMP_EFFECT
how many % of ENVIRO_SUN_INCREMENT is reduced by fog
Definition constants.c:680
const float ENVIRO_HEATISOLATION_VEST_WEIGHT
weight of back for the sum of heat isolation
Definition constants.c:699
const float ENVIRO_ITEM_HEAT_TRANSFER_COEF
how many times slower is wetting/drying items in backpacks
Definition constants.c:684
const float ENVIRO_TICKS_TO_WETNESS_CALCULATION
in secs. how often should enviro effet process
Definition constants.c:672
const float ENVIRO_FOG_TEMP_EFFECT
how many % of environment temperature can be lowered by clouds
Definition constants.c:681
const float ENVIRO_PLAYER_HEATBUFFER_TICK
How much heat buffer increases per one enviro tick.
Definition constants.c:706
const float ENVIRO_PLAYER_HEATBUFFER_DECREASE
impact of enviro temperature on player (lower value = higher, cannot be zero or below!...
Definition constants.c:704
const float ENVIRO_HEATCOMFORT_BODYPARTS_WEIGHT
how much this head parts (clothing) affects final heatcomfort
Definition constants.c:696
const float ENVIRO_HEATCOMFORT_HEADPARTS_WEIGHT
when is sun highest on sky
Definition constants.c:695
const float ENVIRO_HEATISOLATION_BACK_WEIGHT
how much this feet parts (clothing) affects final heatcomfort
Definition constants.c:698
const float ENVIRO_TICK_ROOF_RC_CHECK
each X (ticks) is processed wetness on items on player
Definition constants.c:673
const float ENVIRO_TEMPERATURE_INSIDE_VEHICLE_COEF
increases temp in interiors
Definition constants.c:689
const float ENVIRO_TEMP_SOURCES_LOOKUP_RADIUS
Definition constants.c:721
const float ENVIRO_WIND_EFFECT
windchill effect on base temperature
Definition constants.c:692
const float ENVIRO_TICK_RATE
Definition constants.c:671
const float ENVIRO_PLAYER_COMFORT_TEMP
highest temperature(deg Celsius) where the player gets highest possible heat comfort (1)
Definition constants.c:702
const float ENVIRO_PLAYER_HEATBUFFER_INCREASE
Multiplier of enviro temperature for heat buffer decrease (after its static timer runs out)
Definition constants.c:705
const float ENVIRO_TEMPERATURE_INSIDE_COEF
amount of ?C reduced for each 100 meteres of height above water level
Definition constants.c:688
const float ENVIRO_HEATCOMFORT_FEETPARTS_WEIGHT
how much this body parts (clothing) affects final heatcomfort
Definition constants.c:697
const float ENVIRO_DEFAULT_ENTITY_HEAT
how many time is water colder than air
Definition constants.c:686
const float ENVIRO_TEMPERATURE_WIND_COEF
Definition constants.c:691
const float ENVIRO_LOW_TEMP_LIMIT
weight of vest for the sum of heat isolation
Definition constants.c:700
const float STATE_DAMP
Definition constants.c:784
const float STATE_SOAKING_WET
Definition constants.c:782
const float STATE_WET
Definition constants.c:783
const int LIQUID_WATER
Definition constants.c:504
const int LIQUID_RIVERWATER
Definition constants.c:505
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float SqrFloat(float f)
Returns squared value.
static proto float Min(float x, float y)
Returns smaller of two given values.
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 AbsFloat(float f)
Returns absolute value.