10class EnvironmentSnapshotData
18 bool m_UseTemperatureSources =
false;
19 float m_TemperatureSourceDistance = 1.0;
69 private bool m_IsUnderRoofBuilding;
101 #ifdef ENABLE_LOGGING
102 bool m_DebugLogDryWet =
false;
103 bool m_DebugLogItemHeat =
false;
208 void Update(
float pDelta)
286 bool IsTemperatureSet()
315 return m_Player.IsSoundInsideBuilding();
334 return parent.IsAnyInherited(typenames);
343 private bool IsUnderRoofBuilding()
345 return m_IsUnderRoofBuilding;
371 if (IsChildOfType({
Car}))
374 if (car && car.EngineIsOn())
394 if (IsChildOfType({
Car}))
397 m_IsUnderRoofBuilding =
false;
402 vector hitPosition, hitNormal;
404 vector to = from +
"0 25 0";
408 m_IsUnderRoof =
DayZPhysics.RayCastBullet(from, to, collisionLayerMask, null, hitObject, hitPosition, hitNormal, hitFraction);
410 m_IsUnderRoofBuilding = hitObject && hitObject.IsInherited(
House);
433 g_Game.SurfaceUnderObjectByBoneCorrectedLiquid(
m_Player, SurfaceAnimationBone.RightFrontLimb, surfType, liquidType);
440 HumanMovementState hms =
new HumanMovementState();
451 if (IsUnderRoofBuilding())
458 g_Game.SurfaceUnderObjectExCorrectedLiquid(
m_Player, surfType, impact, liquidType);
491 if (IsUnderRoofBuilding())
524 temperature = waterBodyTemperature -
m_WorldData.m_WaterContactTemperatureModifier;
531 temperature +=
m_WorldData.m_TemperatureInsideBuildingsModifier;
533 else if (IsChildOfType({
Car}))
535 temperature +=
Math.AbsFloat(temperature *
GameConstants.ENVIRO_TEMPERATURE_INSIDE_VEHICLE_COEF);
600 if (weatherEffect <= 0)
605 wetDelta = -(
GameConstants.ENVIRO_DRY_INCREMENT * weatherEffect * tempEffect);
628 HumanCommandMove hcm =
m_Player.GetCommand_Move();
644 m_Rain = weather.GetRain().GetActual();
645 m_Snowfall = weather.GetSnowfall().GetActual();
647 m_Fog = weather.GetFog().GetActual();
648 m_Clouds = weather.GetOvercast().GetActual();
649 m_Wind = weather.GetWindMagnitude().GetActual();
698 int playerAttachmentCount =
m_Player.GetInventory().AttachmentCount();
700 #ifdef ENABLE_LOGGING
701 LogDryWetProcess(
string.Format(
"Environment :: ProcessItemsWetness (update interval=%1s)",
GameConstants.ENVIRO_TICK_RATE));
703 for (
int attIdx = 0; attIdx < playerAttachmentCount; ++attIdx)
705 attachment =
m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
706 if (attachment.IsItemBase())
708 int attachmentSlotsCount = attachment.GetInventory().GetSlotIdCount();
709 for (
int attachmentSlotId = 0; attachmentSlotId < attachmentSlotsCount; ++attachmentSlotId)
711 int attachmentSlot = attachment.GetInventory().GetSlotId(attachmentSlotId);
712 for (
int i = 0; i < pSlotIds.Count(); ++i)
714 if (attachmentSlot == pSlotIds.Get(i))
727 #ifdef ENABLE_LOGGING
728 LogDryWetProcess(
"==========");
737 bool isParentWet =
false;
738 bool parentContainsLiquid =
false;
741 if (pItem.GetInventory().GetCurrentInventoryLocation(iLoc))
752 if ((parentItem.GetLiquidType() != 0) && (parentItem.GetQuantity() > 0))
753 parentContainsLiquid =
true;
763 if (isParentWet || parentContainsLiquid)
765 float soakingCoef = 0;
766 if (parentContainsLiquid)
768 soakingCoef = pItem.GetSoakingIncrement(
"parentWithLiquid");
769 #ifdef ENABLE_LOGGING
770 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);
773 else if (isParentWet && parentItem)
775 if (pItem.GetWet() < parentItem.GetWet())
778 #ifdef ENABLE_LOGGING
779 LogDryWetProcess(
string.Format(
"%1 (soak coef=%2/s, current wetness=%3) [parent wet]", pItem.GetDisplayName(), soakingCoef /
GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
785 #ifdef ENABLE_LOGGING
786 LogDryWetProcess(
string.Format(
"%1 (soak coef=%2/s, current wetness=%3) [normal]", pItem.GetDisplayName(), soakingCoef /
GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
790 pItem.AddWet(soakingCoef);
792 if (pItem.GetInventory().GetCargo())
794 int inItemCount = pItem.GetInventory().GetCargo().GetItemCount();
795 for (
int i = 0; i < inItemCount; ++i)
798 if (
Class.CastTo(inItem, pItem.GetInventory().GetCargo().GetItem(i)))
803 int attCount = pItem.GetInventory().AttachmentCount();
806 for (
int attIdx = 0; attIdx < attCount; ++attIdx)
808 EntityAI attachment = pItem.GetInventory().GetAttachmentFromIndex(attIdx);
827 int attCount =
m_Player.GetInventory().AttachmentCount();
829 #ifdef ENABLE_LOGGING
830 LogDryWetProcess(
string.Format(
"Environment :: ProcessItemsDryness (update interval=%1s)",
GameConstants.ENVIRO_TICK_RATE));
838 distance =
Math.Max(distance, 0.1);
839 drynessData.m_TemperatureSourceDistance = distance;
840 #ifdef ENABLE_LOGGING
841 LogDryWetProcess(
string.Format(
"distance to heatsource: %1 m", distance));
845 for (
int attIdx = 0; attIdx < attCount; ++attIdx)
847 attachment =
m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
848 if (attachment && attachment.IsItemBase())
861 #ifdef ENABLE_LOGGING
862 LogDryWetProcess(
"==========");
876 float dryingIncrement = pItem.GetDryingIncrement(
"player");
877 if (pDrynessData.m_UseTemperatureSources)
878 dryingIncrement = pItem.GetDryingIncrement(
"playerHeatSource");
881 bool isParentWet =
false;
882 bool parentContainsLiquid =
false;
885 if (pItem.GetInventory().GetCurrentInventoryLocation(iLoc))
896 if ((parentItem.GetLiquidType() != 0) && (parentItem.GetQuantity() > 0))
897 parentContainsLiquid =
true;
905 float dryingCoef = 0;
907 if (!isParentWet && !parentContainsLiquid)
910 dryingCoef = (-1 *
GameConstants.ENVIRO_TICK_RATE * dryingIncrement) / pDrynessData.m_TemperatureSourceDistance;
913 #ifdef ENABLE_LOGGING
914 LogDryWetProcess(
string.Format(
"%1 (dry coef=%2/s, current wetness=%3) [normal]", pItem.GetDisplayName(), dryingCoef /
GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
916 pItem.AddWet(dryingCoef);
919 if (pItem.GetInventory().GetCargo())
921 int inItemCount = pItem.GetInventory().GetCargo().GetItemCount();
922 for (
int i = 0; i < inItemCount; ++i)
925 if (
Class.CastTo(inItem, pItem.GetInventory().GetCargo().GetItem(i)))
930 int attCount = pItem.GetInventory().AttachmentCount();
933 for (
int attIdx = 0; attIdx < attCount; ++attIdx)
935 EntityAI attachment = pItem.GetInventory().GetAttachmentFromIndex(attIdx);
937 if (
ItemBase.CastTo(itemAtt, attachment))
943 if (parentContainsLiquid)
946 dryingCoef = (
GameConstants.ENVIRO_TICK_RATE * pItem.GetSoakingIncrement(
"parentWithLiquid")) / pDrynessData.m_TemperatureSourceDistance;
947 #ifdef ENABLE_LOGGING
948 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);
950 pItem.AddWet(dryingCoef);
956 dryingCoef = (
GameConstants.ENVIRO_TICK_RATE * pItem.GetSoakingIncrement(
"wetParent")) / pDrynessData.m_TemperatureSourceDistance;
957 #ifdef ENABLE_LOGGING
958 LogDryWetProcess(
string.Format(
"%1 (dry coef=%2/s, current wetness=%3) [parent wet]", pItem.GetDisplayName(), dryingCoef /
GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
960 pItem.AddWet(dryingCoef);
975 float hcBodyPartTotal, hcBodyPart;
976 float hBodyPartTotal, hBodyPart;
978 float heatComfortSum = 0.0;
979 float heatItems = 0.0;
981 #ifdef ENABLE_LOGGING
982 LogItemHeat(
"====================");
985 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
987 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
989 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
991 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
993 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
995 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
997 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
999 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
1001 hcBodyPartTotal += hcBodyPart; hBodyPartTotal += hBodyPart;
1010 heatItems = hBodyPartTotal;
1011 heatComfortSum = hcBodyPartTotal;
1012 heatComfortSum += hcPenaltyTotal;
1016 if (
m_Player.GetStomach().GetStomachVolume() > 0.0)
1018 float stomachContentTemperature =
m_Player.GetStomach().GetStomachTemperature();
1019 if (stomachContentTemperature <
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT)
1021 stomachContentTemperature =
Math.Remap(
1026 stomachContentTemperature,
1029 else if (stomachContentTemperature >
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1031 stomachContentTemperature =
Math.Remap(
1036 stomachContentTemperature,
1040 stomachContentTemperature = 0.0;
1042 heatComfortSum += stomachContentTemperature *
GameConstants.ENVIRO_STOMACH_WEIGHT;
1054 targetHeatComfort =
Math.Clamp(targetHeatComfort, 0.0,
m_Player.GetStatHeatComfort().GetMax());
1056 targetHeatComfort =
Math.Clamp(targetHeatComfort,
m_Player.GetStatHeatComfort().GetMin(),
m_Player.GetStatHeatComfort().GetMax());
1058 targetHeatComfort =
Math.Round(targetHeatComfort * 100) * 0.01;
1060 float dynamicHeatComfort;
1063 float direction = 1.0;
1064 if (targetHeatComfort < 0.0)
1073 dynamicHeatComfort =
Math.Round(dynamicHeatComfort * 100) * 0.01;
1090 float targetHeatComfort = 0.0;
1096 m_Player.GetStatHeatComfort().Set(dynamicHeatComfort);
1109 float heatBufferCap =
Math.InverseLerp(0.0,
GameConstants.ENVIRO_HEATCOMFORT_WEIGHT_SUMMARY, data.m_ClothingHeatComfort);
1110 float heatBufferMax =
GameConstants.ENVIRO_PLAYER_HEATBUFFER_CAPACITY_MIN + heatBufferCap * (1 -
GameConstants.ENVIRO_PLAYER_HEATBUFFER_CAPACITY_MIN);
1111 m_Player.SetHeatBufferDynamicMax(heatBufferMax);
1118 float heatBufferValueCorrection =
GameConstants.ENVIRO_PLAYER_HEATBUFFER_INCREASE / (heatBufferMax * ((-
GameConstants.ENVIRO_PLAYER_HEATBUFFER_TEMP_AFFECT * data.m_TargetHeatComfort) + 1 ));
1119 heatBuffer.Add(-heatBufferValueCorrection);
1123 float increaseRate = 0.0;
1124 float decreaseRate = 0.0;
1127 increaseRate =
GameConstants.ENVIRO_PLAYER_HEATBUFFER_INCREASE / (heatBufferMax * (( -
GameConstants.ENVIRO_PLAYER_HEATBUFFER_TEMP_AFFECT * data.m_TargetHeatComfort) + 1 ));
1128 decreaseRate =
GameConstants.ENVIRO_PLAYER_HEATBUFFER_DECREASE / (heatBufferMax * ((
GameConstants.ENVIRO_PLAYER_HEATBUFFER_TEMP_AFFECT * data.m_TargetHeatComfort) + 1 ));
1130 float decreaseRateByHeatBufferStageCoef = 1;
1134 float heatBufferMaxInversed =
Math.InverseLerp(
HeatBufferMdfr.STAGE_THRESHOLDS[1], 1.0, heatBufferMax);
1135 switch (
m_Player.GetHeatBufferStage())
1138 decreaseRateByHeatBufferStageCoef =
Math.Lerp(
1139 GameConstants.ENVIRO_PLAYER_HEATBUFFER_STAGE_RATELIMIT[2][0],
1140 GameConstants.ENVIRO_PLAYER_HEATBUFFER_STAGE_RATELIMIT[2][1],
1141 heatBufferMaxInversed,
1145 decreaseRateByHeatBufferStageCoef =
Math.Lerp(
1146 GameConstants.ENVIRO_PLAYER_HEATBUFFER_STAGE_RATELIMIT[1][0],
1147 GameConstants.ENVIRO_PLAYER_HEATBUFFER_STAGE_RATELIMIT[1][1],
1148 heatBufferMaxInversed,
1155 decreaseRateByHeatBufferStageCoef =
GameConstants.ENVIRO_PLAYER_HEATBUFFER_STAGE_RATELIMIT[1][0];
1158 decreaseRate *= decreaseRateByHeatBufferStageCoef;
1169 heatBuffer.Add(-decreaseRate);
1176 if (applicableHeatbuffer > 0.0)
1177 heatBuffer.Add(-decreaseRate);
1178 else if (applicableHeatbuffer != 0.0 && !
m_Player.GetModifiersManager().IsModifierActive(
eModifiers.MDF_HEATBUFFER))
1179 heatBuffer.Set(0.0);
1186 if (applicableHeatbuffer < heatBufferMax)
1188 heatBuffer.Add(increaseRate);
1192 else if (applicableHeatbuffer > 0.0)
1193 heatBuffer.Add(-decreaseRate);
1194 else if (applicableHeatbuffer != 0.0 && !
m_Player.GetModifiersManager().IsModifierActive(
eModifiers.MDF_HEATBUFFER))
1195 heatBuffer.Set(0.0);
1205 float applicableHeatbuffer =
Math.Round((heatBuffer.Get() / heatBuffer.GetMax()) * 1000) * 0.001;
1207 return applicableHeatbuffer;
1221 int attCount =
m_Player.GetInventory().AttachmentCount();
1222 for (
int attIdx = 0; attIdx < attCount; ++attIdx)
1224 attachment =
m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
1226 int attachmentSlot = attachment.GetInventory().GetSlotId(0);
1229 for (
int i = 0; i < pBodyPartIds.Count(); ++i)
1231 if (attachmentSlot == pBodyPartIds[i])
1233 float heatPermCoef = item.GetHeatPermeabilityCoef();
1252 float heatPermCoef = item.GetHeatPermeabilityCoef();
1263 float heatPermCoef = heatPermeabilityCoef;
1266 int inventoryAttCount = item.GetInventory().AttachmentCount();
1267 if (inventoryAttCount > 0)
1270 for (
int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
1272 if (
Class.CastTo(attachmentItem,item.GetInventory().GetAttachmentFromIndex(inAttIdx)))
1274 heatPermCoef = heatPermeabilityCoef;
1275 heatPermCoef *= attachmentItem.GetHeatPermeabilityCoef();
1287 if (item.GetInventory().GetCargo())
1289 int inventoryItemCount = item.GetInventory().GetCargo().GetItemCount();
1290 if (inventoryItemCount > 0)
1293 for (
int j = 0; j < inventoryItemCount; ++j)
1295 if (
Class.CastTo(inventoryItem,item.GetInventory().GetCargo().GetItem(j)))
1297 heatPermCoef = heatPermeabilityCoef;
1298 heatPermCoef *= inventoryItem.GetHeatPermeabilityCoef();
1314 float targetTemperature =
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE;
1315 bool globalCooling =
true;
1321 globalCooling =
false;
1324 if (item.GetTemperature() != targetTemperature || !item.IsFreezeThawProgressFinished())
1326 TemperatureDataInterpolated temperatureData =
new TemperatureDataInterpolated(
1331 heatPermeabilityCoef,
1333 temperatureData.m_UseGlobalCooling = globalCooling;
1335 item.SetTemperatureEx(temperatureData);
1358 int attCount =
m_Player.GetInventory().AttachmentCount();
1359 for (
int attIdx = 0; attIdx < attCount; ++attIdx)
1361 EntityAI attachment =
m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
1362 if (attachment.IsClothing())
1365 int attachmentSlot = attachment.GetInventory().GetSlotId(0);
1367 if (attachmentSlot == pBodyPartId)
1369 #ifdef ENABLE_LOGGING
1370 LogItemHeat(
string.Format(
"BodyPartHeatProperties (%1)",
EnumTools.EnumToString(
InventorySlots, pBodyPartId)));
1373 float itemHeatcomfort = 0;
1374 float itemTemperature = 0;
1377 int inventoryAttCount = item.GetInventory().AttachmentCount();
1378 if (inventoryAttCount > 0)
1380 #ifdef ENABLE_LOGGING
1381 LogItemHeat(
string.Format(
"attachments:"),
false);
1383 for (
int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
1385 EntityAI inAttachment = item.GetInventory().GetAttachmentFromIndex(inAttIdx);
1387 if (attachmentItem && attachmentItem.CanHaveTemperature())
1389 itemTemperature = attachmentItem.GetTemperature();
1390 if (itemTemperature < GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT || itemTemperature >
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1392 itemHeatcomfort = NormalizedTemperature(itemTemperature) * attachmentItem.GetQuantityNormalizedScripted() * attachmentItem.GetTemperaturePerQuantityWeight();
1393 #ifdef ENABLE_LOGGING
1394 LogItemHeat(
string.Format(
"%1: temperature=%2 heat=%3", attachmentItem, itemTemperature, pHeat),
true);
1396 pHeat += itemHeatcomfort;
1401 if (item.GetInventory().GetCargo())
1403 int inventoryItemCount = item.GetInventory().GetCargo().GetItemCount();
1405 if (inventoryItemCount > 0)
1407 #ifdef ENABLE_LOGGING
1408 LogItemHeat(
string.Format(
"cargo:"),
false);
1410 for (
int j = 0; j < inventoryItemCount; ++j)
1412 ItemBase inventoryItem =
ItemBase.Cast(item.GetInventory().GetCargo().GetItem(j));
1413 if (inventoryItem && inventoryItem.CanHaveTemperature())
1415 itemTemperature = inventoryItem.GetTemperature();
1416 if (itemTemperature < GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT || itemTemperature >
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1418 itemHeatcomfort = NormalizedTemperature(itemTemperature) * inventoryItem.GetQuantityNormalizedScripted() * inventoryItem.GetTemperaturePerQuantityWeight();
1419 #ifdef ENABLE_LOGGING
1420 LogItemHeat(
string.Format(
"%1: temperature=%2 heat=%3", inventoryItem, itemTemperature, itemHeatcomfort),
true);
1422 pHeat += itemHeatcomfort;
1429 pHeatComfort = MiscGameplayFunctions.GetCurrentItemHeatIsolation(item) * pCoef;
1431 #ifdef ENABLE_LOGGING
1432 LogItemHeat(
string.Format(
"overall heat from items=%1 (coef applied)", pHeat));
1450 float penalty = 0.0;
1456 penalty +=
GameConstants.ENVIRO_ISOLATION_WETFACTOR_DRENCHED;
1479 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects,
QueryFlags.STATIC|
QueryFlags.DYNAMIC);
1481 foreach (
EntityAI nearestEntity : nearestObjects)
1483 if (nearestEntity.IsUniversalTemperatureSource() && nearestEntity !=
m_Player)
1486 if (!nearestEntity.GetUniversalTemperatureSource().GetLambda().AffectsPlayer())
1490 if (
vector.DistanceSq(pos, nearestEntity.GetPosition()) >
Math.SqrFloat(nearestEntity.GetUniversalTemperatureSource().GetMaxRange()))
1497 if (
m_Player.GetItemInHands() &&
m_Player.GetItemInHands().IsUniversalTemperatureSource())
1521 float itemCoefAverage = 0.0;
1525 itemCoefAverage += tempSource.GetTemperatureItemCoef();
1527 itemCoefAverage /= UTScount;
1530 float min = MiscGameplayFunctions.GetMinValue(utsTemperatures);
1531 float max = MiscGameplayFunctions.GetMaxValue(utsTemperatures);
1533 if (max > 0 && min < 0)
1571 float distance =
vector.Distance(
m_Player.GetPosition(), uts.GetPosition());
1572 distance =
Math.Max(distance, 0.1);
1573 float temperature = 0;
1576 if (distance > uts.GetFullRange())
1578 float distFactor =
Math.InverseLerp(uts.GetMaxRange(), uts.GetFullRange(), distance);
1579 temperature = uts.GetTemperatureCap() * distFactor;
1583 temperature = uts.GetTemperatureCap();
1592 #ifdef DIAG_DEVELOPER
1593 EnvDebugData GetEnvDebugData()
1595 EnvDebugData data =
new EnvDebugData();
1600 void ShowEnvDebugPlayerInfo(
bool enabled)
1602 EnvDebugData data = GetEnvDebugData();
1603 DisplayEnvDebugPlayerInfo(enabled, data);
1606 static void DisplayEnvDebugPlayerInfo(
bool enabled, EnvDebugData data)
1616 DbgUI.Text(
string.Format(
"Heat comfort(target): %1", data.m_PlayerData.m_HeatComfortTarget));
1617 DbgUI.Text(
string.Format(
"Heat comfort(dynamic): %1", data.m_PlayerData.m_HeatComfortDynamic));
1618 DbgUI.Text(
string.Format(
"Inside: %1 (%2)", data.m_PlayerData.m_Inside, data.m_PlayerData.m_Surface));
1619 DbgUI.Text(
string.Format(
"Under roof: %1 (%2)", data.m_PlayerData.m_UnderRoof, data.m_PlayerData.m_UnderRoofTimer));
1620 if ( data.m_PlayerData.m_WaterLevel > 0 )
1622 DbgUI.Text(
string.Format(
"Water Level: %1", data.m_PlayerData.m_WaterLevel));
1631 DbgUI.Text(
string.Format(
"Env temperature (base): %1", data.m_MiscData.m_TemperatureBase));
1632 DbgUI.Text(
string.Format(
"Env temperature (height corrected): %1", data.m_MiscData.m_HeightCorrectedTemperature));
1633 DbgUI.Text(
string.Format(
"Env temperature (modfied): %1", data.m_MiscData.m_TemperatureModified));
1634 DbgUI.Text(
string.Format(
"Wind magnitude(surface mult): %1 (x%2)", data.m_WeatherData.m_Wind, data.m_WeatherData.m_WindModifier));
1635 DbgUI.Text(
string.Format(
"Rain: %1", data.m_WeatherData.m_Rain));
1636 DbgUI.Text(
string.Format(
"Snow: %1", data.m_WeatherData.m_Snowfall));
1638 DbgUI.Text(
string.Format(
"Fog: %1", data.m_WeatherData.m_Fog));
1639 DbgUI.Text(
string.Format(
"Clouds: %1", data.m_WeatherData.m_Clouds));
1640 DbgUI.Text(
string.Format(
"Wet delta: %1", data.m_MiscData.m_WetDelta));
1645 void FillDebugWeatherData(EnvDebugWeatherData data)
1659 message +=
"Player stats";
1661 message +=
"\nHeat comfort(dynamic): " +
m_HeatComfort.ToString();
1664 string impact, surfaceType;
1665 g_Game.SurfaceUnderObjectExCorrectedLiquid(
m_Player, surfaceType, impact, liquidType);
1668 message +=
"\nSurface: " + surfaceType;
1669 message +=
"\nLiquid: " + liquidType;
1676 message +=
"\n\nWeather stats";
1681 message +=
"\nRain: " +
m_Rain.ToString();
1682 message +=
"\nSnow: " +
m_Snowfall.ToString();
1684 message +=
"\nFog: " +
m_Fog.ToString();
1685 message +=
"\nClouds: " +
m_Clouds.ToString();
1686 message +=
"\nWet delta: " +
GetWetDelta().ToString();
1706 private bool IsNeutralTemperature(
float temperature,
float lowerLimit =
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT,
float upperLimit =
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1708 if (temperature >= lowerLimit && temperature <= upperLimit)
1714 private float NormalizedTemperature(
float temperature,
float lowerLimit =
GameConstants.ENVIRO_LOW_TEMP_LIMIT,
float upperLimit =
GameConstants.ENVIRO_HIGH_TEMP_LIMIT)
1716 if (temperature >=
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT && temperature <=
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1719 if (temperature <
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT)
1720 return Math.Clamp(
Math.InverseLerp(lowerLimit,
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT, temperature), -1.0, -0.1);
1722 if (temperature >
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1723 return Math.Clamp(
Math.InverseLerp(
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT, upperLimit, temperature), 0.1, 1.0);
1729 #ifdef ENABLE_LOGGING
1730 private void LogDryWetProcess(
string message,
bool indented =
false)
1732 if (m_DebugLogDryWet)
1734 string indentation =
"";
1736 indentation =
"|--";
1738 Debug.Log(
string.Format(
"%1 %2", indentation, message));
1743 #ifdef ENABLE_LOGGING
1744 private void LogItemHeat(
string message,
bool indented =
false)
1746 if (m_DebugLogItemHeat)
1748 string indentation =
"";
1750 indentation =
"|--";
1752 Debug.Log(
string.Format(
"%1 %2", indentation, message));
1787 return temperature_reduction;
1796 if (pBodyPartIds.Count() > 0)
1798 #ifdef ENABLE_LOGGING
1799 LogItemHeat(
string.Format(
"BodyPartHeatProperties (%1)",
EnumTools.EnumToString(
InventorySlots, pBodyPartIds[0])));
1802 int attCount =
m_Player.GetInventory().AttachmentCount();
1803 for (
int attIdx = 0; attIdx < attCount; ++attIdx)
1805 EntityAI attachment =
m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
1806 if (attachment.IsClothing())
1809 int attachmentSlot = attachment.GetInventory().GetSlotId(0);
1812 for (
int i = 0; i < pBodyPartIds.Count(); ++i)
1814 if (attachmentSlot == pBodyPartIds[i])
1816 float heatIsoMult = 1.0;
1818 heatIsoMult =
GameConstants.ENVIRO_HEATISOLATION_BACK_WEIGHT;
1820 heatIsoMult =
GameConstants.ENVIRO_HEATISOLATION_VEST_WEIGHT;
1822 pHeatComfort += heatIsoMult * MiscGameplayFunctions.GetCurrentItemHeatIsolation(item);
1824 float itemHeatcomfort = 0;
1825 float itemTemperature = 0;
1828 int inventoryAttCount = item.GetInventory().AttachmentCount();
1829 if (inventoryAttCount > 0)
1831 #ifdef ENABLE_LOGGING
1832 LogItemHeat(
string.Format(
"attachments:"),
false);
1834 for (
int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
1836 EntityAI inAttachment = item.GetInventory().GetAttachmentFromIndex(inAttIdx);
1838 if (attachmentItem && attachmentItem.CanHaveTemperature())
1840 itemTemperature = attachmentItem.GetTemperature();
1841 if (itemTemperature < GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT || itemTemperature >
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1843 itemHeatcomfort = NormalizedTemperature(itemTemperature) * attachmentItem.GetQuantityNormalizedScripted() * attachmentItem.GetTemperaturePerQuantityWeight();
1844 #ifdef ENABLE_LOGGING
1845 LogItemHeat(
string.Format(
"%1: temperature=%2 heat=%3", attachmentItem, itemTemperature, pHeat),
true);
1846 pHeat += itemHeatcomfort;
1852 if (item.GetInventory().GetCargo())
1854 int inventoryItemCount = item.GetInventory().GetCargo().GetItemCount();
1856 if (inventoryItemCount > 0)
1858 #ifdef ENABLE_LOGGING
1859 LogItemHeat(
string.Format(
"cargo:"),
false);
1861 for (
int j = 0; j < inventoryItemCount; ++j)
1863 ItemBase inventoryItem =
ItemBase.Cast(item.GetInventory().GetCargo().GetItem(j));
1864 if (inventoryItem && inventoryItem.CanHaveTemperature())
1866 itemTemperature = inventoryItem.GetTemperature();
1867 if (itemTemperature < GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT || itemTemperature >
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1869 itemHeatcomfort = NormalizedTemperature(itemTemperature) * inventoryItem.GetQuantityNormalizedScripted() * inventoryItem.GetTemperaturePerQuantityWeight();
1870 #ifdef ENABLE_LOGGING
1871 LogItemHeat(
string.Format(
"%1: temperature=%2 heat=%3", inventoryItem, itemTemperature, itemHeatcomfort),
true);
1873 pHeat += itemHeatcomfort;
1884 pHeatComfort += (pHeatComfort / pBodyPartIds.Count()) * pCoef;
1886 #ifdef ENABLE_LOGGING
1887 LogItemHeat(
string.Format(
"overall heat from items=%1 (coef applied)", pHeat));
1895 EnvironmentSnapshotData data =
new EnvironmentSnapshotData();
1928 return IsChildOfType({
Car});
1932#ifdef DIAG_DEVELOPER
1933class EnvDebugPlayerData :
Param
1935 float m_HeatComfortDynamic;
1936 float m_HeatComfortTarget;
1940 int m_UnderRoofTimer;
1945 m_HeatComfortTarget = env.GetTargetHeatComfort();
1946 m_HeatComfortDynamic = player.GetStatHeatComfort().Get();
1947 m_Inside = env.IsInsideBuilding();
1949 m_UnderRoof = env.IsUnderRoof();
1950 m_UnderRoofTimer = env.GetNextRoofCheck();
1957 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));
1962 return ctx.Write(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);
1966class EnvDebugMiscData :
Param
1968 float m_TemperatureBase;
1969 float m_TemperatureModified;
1970 float m_HeightCorrectedTemperature;
1973 void Synch(Environment env)
1975 m_TemperatureBase =
g_Game.GetMission().GetWorldData().GetBaseEnvTemperature();
1976 m_TemperatureModified = env.GetTemperature();
1977 m_HeightCorrectedTemperature = m_TemperatureBase - env.GetTemperatureHeightCorrection();
1978 m_WetDelta = env.GetWetDelta();
1983 return ctx.Write(m_TemperatureBase) && ctx.Write(m_TemperatureModified) && ctx.Write(m_HeightCorrectedTemperature) && ctx.Write(m_WetDelta);
1988 return ctx.Read(m_TemperatureBase) && ctx.Read(m_TemperatureModified) && ctx.Read(m_HeightCorrectedTemperature) && ctx.Read(m_WetDelta);
1992class EnvDebugWeatherData :
Param
1995 float m_WindModifier;
2001 void Synch(Environment env)
2003 env.FillDebugWeatherData(
this);
2017class EnvDebugData :
Param
2019 ref EnvDebugPlayerData m_PlayerData =
new EnvDebugPlayerData();
2020 ref EnvDebugMiscData m_MiscData =
new EnvDebugMiscData();
2021 ref EnvDebugWeatherData m_WeatherData =
new EnvDebugWeatherData();
2025 m_PlayerData.Synch(env, player);
2026 m_MiscData.Synch(env);
2027 m_WeatherData.Synch(env);
2032 return m_PlayerData.Serialize(ctx) && m_MiscData.Serialize(ctx) && m_WeatherData.Serialize(ctx);
2037 return m_PlayerData.Deserializer(ctx) && m_MiscData.Deserializer(ctx) && m_WeatherData.Deserializer(ctx);
#define LIQUID_RIVERWATER
#define LIQUID_FRESHWATER
#define LIQUID_STILLWATER
Super root of all classes in Enforce script.
override float GetCurrentWaterLevel()
provides access to slot configuration
override bool IsSelfAdjustingTemperature()
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Serialization general interface. Serializer API works with:
Native class for boats - handles physics simulation.
Keeps information about currently loaded world, like temperature.
float GetTemperature(Object object, EEnvironmentTemperatureComponent properties=EEnvironmentTemperatureComponent.BASE)
Return actual temperature of environment based on provided parameters.
float GetBaseEnvTemperature()
float GetBaseEnvTemperatureAtObject(notnull Object object)
float GetLiquidTypeEnviroTemperature(int liquidType)
float GetTemperatureComponentValue(float temperatureIn, EEnvironmentTemperatureComponent properties=0)
Return value of queried EEnvironmentTemperatureComponent which can be used in future calculation(s)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerConstants
defined in C++
EEnvironmentTemperatureComponent
ref EnvironmentSnapshotData m_EnvironmentSnapshot
void CollectAndSetEnvironmentData()
Sets actual weather related values for further use (rain, snow, wind, etc.)
ref SimpleMovingAverage< float > m_UTSAverageTemperatureBuffer
ref array< UTemperatureSource > m_UTemperatureSources
void SetTargetHeatComfort(float value)
float GetTemperatureHeightCorrection()
bool IsWaterContact()
Is character in contact with water body? (periodically checked - GameConstants.ENVIRO_TICK_RATE).
ref array< int > m_SlotIdsComplete
int m_HeatComfortBehaviorCategory
bool IsInsideBuilding()
Is character inside building? (periodically checked - GameConstants.ENVIRO_TICK_ROOF_RC_CHECK).
float m_UTSAverageTemperature
float CalcTemperatureFromTemperatureSource(notnull UTemperatureSource uts)
void SetAreaGenericColdness()
Determines whether player is in cold area which restricts use of some actions (digging)
void ProcessTemperatureSources()
Processes registered UTSources and calculates resulting m_UTSAverageTemperature.
float m_PlayerTemperature
bool OverridenHeatComfort(out float value)
void CheckUnderRoof()
Checks whether character is sheltered and sets the information.
void AddToEnvironmentTemperature(float pTemperature)
float m_ItemTemperatureCoef
const float SNOWFALL_LIMIT_LOW
float m_EnvironmentTemperature
ref array< int > m_HeadParts
void ApplyDrynessToItemEx(ItemBase pItem, EnvironmentDrynessData pDrynessData)
ref array< int > m_SlotIdsUpper
void ProcessItemsWetness(array< int > pSlotIds)
Soak items at specific Slot ID(s)
float m_HeatSourceTemp
DEPRECATED.
float GetWindModifierPerSurface()
Wind intensity (influence) modifier of temperature value.
float GetApplicableHeatbuffer()
ref array< int > m_SlotIdsLower
void ProcessItemsInHandsTemperature()
Process temperature of item in character hands and cool/warm it to neutral temparature.
void SetEnvironmentSnapshotData()
bool IsUnderRoof()
Is character under roof (periodically checked - GameConstants.ENVIRO_TICK_ROOF_RC_CHECK)....
ref SimpleMovingAverage< float > m_AverageHeatComfortBuffer
const float WATER_LEVEL_MID
float m_Rain
target value of heatcomfort (non-buffered)
void ProcessWetnessByWaterLevel(float pWaterLevel)
Processes items wetness in player possession based on the current water level (the character is in)
float WindEffectTemperatureValue(float temperatureInput)
backward compatibility [<1.28]
const float SNOWFALL_WIND_COMBINED_THRESHOLD
void SetProcessedItemTemperature(ItemBase item, float heatPermeabilityCoef=1.0)
void CollectAndSetPlayerData()
Sets character related value for furher use.
enum EEnvironmentHeatcomfortBehaviorCategory m_ClothingHeatComfort
void ProcessItemHierarchyRecursive(ItemBase item, float heatPermeabilityCoef=1.0)
ref array< int > m_BodyParts
void SetItemHeatingCoef(float val)
void GatherTemperatureSources()
Checks characters proximity for usable Universal Temperature Sources and register them.
const float WATER_LEVEL_LOW
const float WATER_LEVEL_NONE
void OnTemperatureSourcesLeft()
Event fired when characters leave the UTSource proximity.
ref array< int > m_FeetParts
float EnvTempToCoef(float pTemp)
const float WATER_LEVEL_HIGH
EEnvironmentHeatcomfortBehaviorCategory
Categories that are changing behavior of Heat comfort processing.
ref SimpleMovingAverage< float > m_WindAverageBuffer
string GetDebugMessage()
debug
float GetWetDelta()
Calculates soaking/drying delta based on character's location and weather.
bool DetermineHeatcomfortBehavior()
Changes Heat Comfort curve behavior based on where the character is.
void ApplyWetnessToItem(ItemBase pItem)
void BodyPartHeatProperties(int pBodyPartId, float pCoef, out float pHeatComfort, out float pHeat)
Iterate through given body part and calculates heatcofort and item heat value.
float m_HeatBufferCapPrevious
reused as state toggle
bool IsRaining()
Rain phenomenon actual value > RAIN_LIMIT_LOW.
void SetEnvironmentTemperature()
ref array< int > m_SlotIdsBottom
float GetEnvironmentTemperature()
Calculations of temperarute for different situations.
float GetUniversalSourcesTemperageAverage()
float NakedBodyPartHeatComfortPenalty(int pBodyPartSlotId, float pCoef)
Calculates penalty value for heatcomfort - this simulates uncovered body part reaction.
void SetHeatcomfortDirectly()
void ProcessWetnessByRain()
void OnTemperatureSourcesEnter()
Event fired when characters enters into UTSource proximity.
void ApplyDrynessToItem(ItemBase pItem)
bool IsSnowing()
Snowfall phenomenon actual value > SNOWFALL_LIMIT_LOW.
float m_RoofCheckTimer
keeps wetness of most wet item in player's possesion
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.
float GetPlayerHeat()
Character's heat (calculated from movement speed multiplied by constant)
float m_TargetHeatComfort
player's heatcomfort (buffered, stored in player stats)
float GetTargetHeatComfort()
bool m_HasTemperatureSources
void ProcessHeatComfort()
Calculates and process player's heatcomfort related to defined body parts.
void ProcessHeatBuffer(EnvironmentSnapshotData data)
void ProcessItemsTemperature(array< int > pBodyPartIds)
Iterate through items in player posession (by given body parts) and cool/warm them to neutral tempara...
void CheckWaterContact(out float pWaterLevel)
Checks player's contanct with water.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
class JsonUndergroundAreaTriggerData GetPosition
void PlayerStat(T min, T max, T init, string label, int flags)
class PresenceNotifierNoiseEvents windowPosX
dbgUI settings
void Synch(EntityAI victim)
keeping "step" here for consistency only