74 float newTempFraction = (1/fraction) * temperature;
81 bool ProcessDigestion(
float digestion_points, out
float water, out
float energy, out
float toxicity, out
float volume, out
int agents, out
float consumed_amount)
92 float energy_per_unit = profile.
GetEnergy() / 100;
97 if (digestability == 0)
102 float consumed_quantity = digestion_points * digestability;
108 if (consumed_quantity > 0)
110 water = consumed_quantity * water_per_unit;
111 energy = consumed_quantity * energy_per_unit;
112 toxicity = consumed_quantity * toxicity_per_unit;
114 return consumed_quantity;
169 float reduction = percent * 0.01;
173 item.AddAmount( -(item.GetAmount() * reduction) );
191 int hash = classname.
Hash();
213 all_paths.Insert(
"CfgVehicles");
214 all_paths.Insert(
"cfgLiquidDefinitions");
220 int consumable_count;
221 for(
int i = 0; i < all_paths.Count(); i++)
223 config_path = all_paths.Get(i);
226 for(
int x = 0;
x < children_count;
x++)
229 path = config_path +
" " + child_name;
231 bool should_check = 1;
232 if (config_path ==
"CfgVehicles" && scope == 0)
242 if (has_nutrition || has_stages)
275 if (stomachItemsCount == 0)
280 for (
int i = 0; i < stomachItemsCount; i++)
300 if (stomachItemsCount == 0)
303 float digestionPointsPerItem = (
DIGESTION_POINTS / stomachItemsCount) * delta_time;
305 for (
int i = stomachItemsCount - 1; i >= 0; i--)
308 float water, energy, toxicity, volume, consumedAmount;
311 if (item.
ProcessDigestion(digestionPointsPerItem, water, energy, toxicity, volume, agents, consumedAmount))
318 m_Player.GetStatEnergy().Add(energy);
329 if (amountOfAgents == 0)
330 amountOfAgents = consumedAmount;
346 int highestBit =
Math.
Log2(agents) + 1;
347 for (
int i = 0; i < highestBit; ++i)
349 int agent = (1 << i)& agents;
354 quantity += quantity * rndPct;
355 m_Player.m_AgentPool.DigestAgent(agent, quantity);
362 float amountByAgent = 0.0;
365 if ((item.m_Agents & agent) == agent)
366 amountByAgent += item.m_Amount;
369 return amountByAgent;
383 Print(
"================================");
391 Print(
"itemname:" + itemname);
392 Print(
"amount:" + amount);
393 Print(
"food_stage:" + food_stage);
394 Print(
"agents:" + agents);
398 Print(
"================================");
423 for(
int i = 0; i < count; i++)
432 fraction = (stomachItem.
m_Amount + amount) / amount;
463 ctx.
Write(writeResult);
474 if (!ctx.
Read(checksum))
479 if (!ctx.
Read(count))
483 for (
int i = 0; i < count; ++i)
485 int value, agents, temperature;
486 if (!ctx.
Read(value))
489 if (!ctx.
Read(agents))
492 if (version >= 140 && !ctx.
Read(temperature))
501 int food_stage = value & food_mask;
507 AddToStomach(classname, amount, food_stage, agents, temperature);
513 Print(
"Stomach checksum fail");
528 Param5<int,int,int,float,float> p5 =
new Param5<int,int,int,float,float>(
id, food_stage, agents, amount, temperature);
529 object_out.Insert(p5);
532 object_out.Insert(p1);
534 object_out.Insert(paramTemp);
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void OnStoreSave(ParamsWriteContext ctx)
class ModifierDebugObj STORAGE_VERSION
bool OnStoreLoad(ParamsReadContext ctx, int version)
class OptionSelectorMultistate extends OptionSelector class_name
void AddToStomach(string class_name, float amount, int food_stage=0, int agents=0, float temperature=0)
float GetVolumeContainingAgent01(eAgents agent)
void ReduceContents(float percent)
const int ACCEPTABLE_QUANTITY_MAX
void UpdateStomachTemperature()
const int ACCEPTABLE_FOODSTAGE_MAX
int GetAgentTransferFilter()
float GetStomachTemperature()
static ref map< int, string > m_IDsToNames
const float DIGESTION_POINTS
class StomachItem DIGESTING_WATER
const int quantity_bit_offset
void DigestAgents(int agents, float quantity)
int GetDebugObject(array< ref Param > object_out)
const int DIGESTING_ENERGY
void ProcessNutrients(float delta_time)
static void RegisterItem(string classname, int id)
static string GetClassnameFromID(int id)
float m_StomachTemperature
void SetAgentTransferFilter(int filter_agents)
ref array< ref StomachItem > m_StomachContents
static const bool m_InitData
float GetVolumeContainingAgent(eAgents agent)
static int GetIDFromClassname(string name)
int m_AgentTransferFilter
static ref map< string, int > m_NamesToIDs
void PlayerStomach(PlayerBase player)
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native bool ConfigIsExisting(string path)
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname="", int food_stage=0)
static const float STOMACH_DIGEST_AGENT_RANDOM_MIN
static const float STOMACH_DIGEST_AGENT_RANDOM_MAX
Percents of agents count <-1.0; 1.0>
static const float BLOODY_HANDS_FOOD_POISON_AGENT_INCREMENT
static const float DIGESTION_SPEED
proto bool Write(void value_out)
proto bool Read(void value_in)
void SetFoodStage(int food_stage)
float GetNutritions(float digestion_points, NutritionalProfile profile, out float water, out float energy, out float toxicity)
void StomachItem(string class_name, float amount, NutritionalProfile profile, int foodstage, int agents, float temperature)
ref NutritionalProfile m_Profile
bool ProcessDigestion(float digestion_points, out float water, out float energy, out float toxicity, out float volume, out int agents, out float consumed_amount)
void AddTemperature(float temperature, float fraction)
void AddAmount(float amount)
void AddAgents(int agents)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Serializer ParamsReadContext
proto native CGame GetGame()
Serializer ParamsWriteContext
proto void Print(void var)
Prints content of variable to console/log.
array< string > TStringArray
static proto float Max(float x, float y)
Returns bigger of two given values.
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
static proto float Log2(float x)
Returns the binary (base-2) logarithm of x.
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 proto float Pow(float v, float power)
Return power of v ^ power.
proto native int Hash()
Returns hash of string.