DayZ 1.28
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ SaveAgents()

void SpawnItemOnLocation::SaveAgents ( ParamsWriteContext ctx)
protected

См. определение в файле ItemBase.c строка 8863

8867{
8868 override bool CanPutAsAttachment(EntityAI parent)
8869 {
8870 return true;
8871 }
8872};
8873
8874//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8875
8876class ItemBase extends InventoryItem
8877{
8881
8883
8884 static int m_DebugActionsMask;
8886 // ============================================
8887 // Variable Manipulation System
8888 // ============================================
8889 // Quantity
8890
8891 float m_VarQuantity;
8892 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8894 int m_VarQuantityMin;
8895 int m_VarQuantityMax;
8896 int m_Count;
8897 float m_VarStackMax;
8898 float m_StoreLoadedQuantity = float.LOWEST;
8899 // Wet
8900 float m_VarWet;
8901 float m_VarWetPrev;//for client to know wetness changed during synchronization
8902 float m_VarWetInit;
8903 float m_VarWetMin;
8904 float m_VarWetMax;
8905 // Cleanness
8906 int m_Cleanness;
8907 int m_CleannessInit;
8908 int m_CleannessMin;
8909 int m_CleannessMax;
8910 // impact sounds
8912 bool m_CanPlayImpactSound = true;
8913 float m_ImpactSpeed;
8915 //
8916 float m_HeatIsolation;
8917 float m_ItemModelLength;
8918 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8920 int m_VarLiquidType;
8921 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8922 int m_QuickBarBonus;
8923 bool m_IsBeingPlaced;
8924 bool m_IsHologram;
8925 bool m_IsTakeable;
8926 bool m_ThrowItemOnDrop;
8929 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8930 bool can_this_be_combined; //Check if item can be combined
8931 bool m_CanThisBeSplit; //Check if item can be split
8932 bool m_IsStoreLoad = false;
8933 bool m_CanShowQuantity;
8934 bool m_HasQuantityBar;
8935 protected bool m_CanBeDigged;
8936 protected bool m_IsResultOfSplit
8937
8938 string m_SoundAttType;
8939 // items color variables
8944 //-------------------------------------------------------
8945
8946 // light source managing
8948
8952
8953 //==============================================
8954 // agent system
8955 private int m_AttachedAgents;
8956
8958 void TransferModifiers(PlayerBase reciever);
8959
8960
8961 // Weapons & suppressors particle effects
8966 static int m_LastRegisteredWeaponID = 0;
8967
8968 // Overheating effects
8970 float m_OverheatingShots;
8971 ref Timer m_CheckOverheating;
8972 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8973 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8974 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8975 ref array <ref OverheatingParticle> m_OverheatingParticles;
8976
8978 protected bool m_HideSelectionsBySlot;
8979
8980 // Admin Log
8981 PluginAdminLog m_AdminLog;
8982
8983 // misc
8984 ref Timer m_PhysDropTimer;
8985
8986 // Attachment Locking variables
8987 ref array<int> m_CompatibleLocks;
8988 protected int m_LockType;
8989 protected ref EffectSound m_LockingSound;
8990 protected string m_LockSoundSet;
8991
8992 // ItemSoundHandler
8993 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8994 protected int m_SoundSyncPlay; // id for sound to play
8995 protected int m_SoundSyncStop; // id for sound to stop
8997
8998 //temperature
8999 private float m_TemperaturePerQuantityWeight;
9000
9001 // -------------------------------------------------------------------------
9002 void ItemBase()
9003 {
9004 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
9008
9009 if (!GetGame().IsDedicatedServer())
9010 {
9011 if (HasMuzzle())
9012 {
9014
9016 {
9018 }
9019 }
9020
9022 m_ActionsInitialize = false;
9023 }
9024
9025 m_OldLocation = null;
9026
9027 if (GetGame().IsServer())
9028 {
9029 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
9030 }
9031
9032 if (ConfigIsExisting("headSelectionsToHide"))
9033 {
9035 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
9036 }
9037
9038 m_HideSelectionsBySlot = false;
9039 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
9040 {
9041 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
9042 }
9043
9044 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
9045
9046 m_IsResultOfSplit = false;
9047
9049 }
9050
9051 override void InitItemVariables()
9052 {
9053 super.InitItemVariables();
9054
9055 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
9056 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
9057 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
9058 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
9059 m_VarStackMax = ConfigGetFloat("varStackMax");
9060 m_Count = ConfigGetInt("count");
9061
9062 m_CanShowQuantity = ConfigGetBool("quantityShow");
9063 m_HasQuantityBar = ConfigGetBool("quantityBar");
9064
9065 m_CleannessInit = ConfigGetInt("varCleannessInit");
9067 m_CleannessMin = ConfigGetInt("varCleannessMin");
9068 m_CleannessMax = ConfigGetInt("varCleannessMax");
9069
9070 m_WantPlayImpactSound = false;
9071 m_ImpactSpeed = 0.0;
9072
9073 m_VarWetInit = ConfigGetFloat("varWetInit");
9075 m_VarWetMin = ConfigGetFloat("varWetMin");
9076 m_VarWetMax = ConfigGetFloat("varWetMax");
9077
9078 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
9079 if (IsLiquidContainer() && GetQuantity() != 0)
9081 m_IsBeingPlaced = false;
9082 m_IsHologram = false;
9083 m_IsTakeable = true;
9084 m_CanBeMovedOverride = false;
9088 m_CanBeDigged = ConfigGetBool("canBeDigged");
9089
9090 m_CompatibleLocks = new array<int>();
9091 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
9092 m_LockType = ConfigGetInt("lockType");
9093
9094 //Define if item can be split and set ability to be combined accordingly
9095 m_CanThisBeSplit = false;
9096 can_this_be_combined = false;
9097 if (ConfigIsExisting("canBeSplit"))
9098 {
9099 can_this_be_combined = ConfigGetBool("canBeSplit");
9101 }
9102
9103 m_ItemBehaviour = -1;
9104 if (ConfigIsExisting("itemBehaviour"))
9105 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
9106
9107 //RegisterNetSyncVariableInt("m_VariablesMask");
9108 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9109 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
9110 RegisterNetSyncVariableInt("m_VarLiquidType");
9111 RegisterNetSyncVariableInt("m_Cleanness",0,1);
9112
9113 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
9114 RegisterNetSyncVariableFloat("m_ImpactSpeed");
9115 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
9116
9117 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
9118 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
9119 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
9120 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
9121
9122 RegisterNetSyncVariableBool("m_IsBeingPlaced");
9123 RegisterNetSyncVariableBool("m_IsTakeable");
9124 RegisterNetSyncVariableBool("m_IsHologram");
9125
9126 InitItemSounds();
9128 {
9129 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
9130 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
9131 }
9132
9133 m_LockSoundSet = ConfigGetString("lockSoundSet");
9134
9136 if (ConfigIsExisting("temperaturePerQuantityWeight"))
9137 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
9138
9139 }
9140
9141 override int GetQuickBarBonus()
9142 {
9143 return m_QuickBarBonus;
9144 }
9145
9146 void InitializeActions()
9147 {
9149 if (!m_InputActionMap)
9150 {
9152 m_InputActionMap = iam;
9153 SetActions();
9155 }
9156 }
9157
9158 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
9159 {
9161 {
9162 m_ActionsInitialize = true;
9164 }
9165
9166 actions = m_InputActionMap.Get(action_input_type);
9167 }
9168
9169 void SetActions()
9170 {
9171 AddAction(ActionTakeItem);
9172 AddAction(ActionTakeItemToHands);
9173 AddAction(ActionWorldCraft);
9175 AddAction(ActionAttachWithSwitch);
9176 }
9177
9178 void SetActionAnimOverrides(); // Override action animation for specific item
9179
9180 void AddAction(typename actionName)
9181 {
9182 ActionBase action = ActionManagerBase.GetAction(actionName);
9183
9184 if (!action)
9185 {
9186 Debug.LogError("Action " + actionName + " dosn't exist!");
9187 return;
9188 }
9189
9190 typename ai = action.GetInputType();
9191 if (!ai)
9192 {
9193 m_ActionsInitialize = false;
9194 return;
9195 }
9196
9197 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9198 if (!action_array)
9199 {
9200 action_array = new array<ActionBase_Basic>;
9201 m_InputActionMap.Insert(ai, action_array);
9202 }
9203 if (LogManager.IsActionLogEnable())
9204 {
9205 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9206 }
9207
9208 if (action_array.Find(action) != -1)
9209 {
9210 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
9211 }
9212 else
9213 {
9214 action_array.Insert(action);
9215 }
9216 }
9217
9218 void RemoveAction(typename actionName)
9219 {
9220 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9221 ActionBase action = player.GetActionManager().GetAction(actionName);
9222 typename ai = action.GetInputType();
9223 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9224
9225 if (action_array)
9226 {
9227 action_array.RemoveItem(action);
9228 }
9229 }
9230
9231 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
9232 // Set -1 for params which should stay in default state
9233 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
9234 {
9235 ActionOverrideData overrideData = new ActionOverrideData();
9236 overrideData.m_CommandUID = commandUID;
9237 overrideData.m_CommandUIDProne = commandUIDProne;
9238 overrideData.m_StanceMask = stanceMask;
9239
9240 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
9241 if (!actionMap) // create new map of action > overidables map
9242 {
9243 actionMap = new TActionAnimOverrideMap();
9244 m_ItemActionOverrides.Insert(action, actionMap);
9245 }
9246
9247 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9248
9249 }
9250
9251 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9252
9253 ScriptedLightBase GetLight();
9254
9255 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9256 void LoadParticleConfigOnFire(int id)
9257 {
9258 if (!m_OnFireEffect)
9260
9263
9264 string config_to_search = "CfgVehicles";
9265 string muzzle_owner_config;
9266
9267 if (!m_OnFireEffect.Contains(id))
9268 {
9269 if (IsInherited(Weapon))
9270 config_to_search = "CfgWeapons";
9271
9272 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9273
9274 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9275
9276 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
9277
9278 if (config_OnFire_subclass_count > 0)
9279 {
9280 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9281
9282 for (int i = 0; i < config_OnFire_subclass_count; i++)
9283 {
9284 string particle_class = "";
9285 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
9286 string config_OnFire_entry = config_OnFire_class + particle_class;
9287 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9288 WPOF_array.Insert(WPOF);
9289 }
9290
9291
9292 m_OnFireEffect.Insert(id, WPOF_array);
9293 }
9294 }
9295
9296 if (!m_OnBulletCasingEjectEffect.Contains(id))
9297 {
9298 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9299 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9300
9301 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9302
9303 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9304
9305 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9306 {
9307 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9308
9309 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9310 {
9311 string particle_class2 = "";
9312 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9313 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9314 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9315 WPOBE_array.Insert(WPOBE);
9316 }
9317
9318
9319 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9320 }
9321 }
9322 }
9323
9324 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9326 {
9329
9330 if (!m_OnOverheatingEffect.Contains(id))
9331 {
9332 string config_to_search = "CfgVehicles";
9333
9334 if (IsInherited(Weapon))
9335 config_to_search = "CfgWeapons";
9336
9337 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9338 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9339
9340 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
9341 {
9342
9343 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9344
9346 {
9347 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9348 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9349 Error(error);
9350 return;
9351 }
9352
9353 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9354 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9355
9356
9357
9358 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
9359 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9360
9361 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9362 {
9363 string particle_class = "";
9364 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9365 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9366 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
9367
9368 if (entry_type == CT_CLASS)
9369 {
9370 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9371 WPOOH_array.Insert(WPOF);
9372 }
9373 }
9374
9375
9376 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9377 }
9378 }
9379 }
9380
9381 float GetOverheatingValue()
9382 {
9383 return m_OverheatingShots;
9384 }
9385
9386 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9387 {
9388 if (m_MaxOverheatingValue > 0)
9389 {
9391
9392 if (!m_CheckOverheating)
9394
9396 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9397
9398 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9399 }
9400 }
9401
9402 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9403 {
9405 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9406
9408 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9409
9411 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9412
9414 {
9416 }
9417 }
9418
9420 {
9422 }
9423
9424 void OnOverheatingDecay()
9425 {
9426 if (m_MaxOverheatingValue > 0)
9427 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9428 else
9430
9431 if (m_OverheatingShots <= 0)
9432 {
9435 }
9436 else
9437 {
9438 if (!m_CheckOverheating)
9440
9442 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9443 }
9444
9445 CheckOverheating(this, "", this);
9446 }
9447
9448 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9449 {
9451 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9452 }
9453
9454 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9455 {
9457 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9459 }
9460
9461 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9462 {
9464 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9465 }
9466
9467 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9468 {
9470 m_OverheatingParticles = new array<ref OverheatingParticle>;
9471
9472 OverheatingParticle OP = new OverheatingParticle();
9473 OP.RegisterParticle(p);
9474 OP.SetOverheatingLimitMin(min_heat_coef);
9475 OP.SetOverheatingLimitMax(max_heat_coef);
9476 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9477
9478 m_OverheatingParticles.Insert(OP);
9479 }
9480
9481 float GetOverheatingCoef()
9482 {
9483 if (m_MaxOverheatingValue > 0)
9485
9486 return -1;
9487 }
9488
9490 {
9492 {
9493 float overheat_coef = GetOverheatingCoef();
9494 int count = m_OverheatingParticles.Count();
9495
9496 for (int i = count; i > 0; --i)
9497 {
9498 int id = i - 1;
9499 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9500 Particle p = OP.GetParticle();
9501
9502 float overheat_min = OP.GetOverheatingLimitMin();
9503 float overheat_max = OP.GetOverheatingLimitMax();
9504
9505 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9506 {
9507 if (p)
9508 {
9509 p.Stop();
9510 OP.RegisterParticle(null);
9511 }
9512 }
9513 }
9514 }
9515 }
9516
9518 {
9520 {
9521 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9522 {
9523 int id = i - 1;
9524 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9525
9526 if (OP)
9527 {
9528 Particle p = OP.GetParticle();
9529
9530 if (p)
9531 {
9532 p.Stop();
9533 }
9534
9535 delete OP;
9536 }
9537 }
9538
9539 m_OverheatingParticles.Clear();
9541 }
9542 }
9543
9545 float GetInfectionChance(int system = 0, Param param = null)
9546 {
9547 return 0.0;
9548 }
9549
9550
9551 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9552 {
9553 return 250;//default value
9554 }
9555
9556 float GetFilterDamageRatio()
9557 {
9558 return 0;
9559 }
9560
9562 bool HasMuzzle()
9563 {
9564 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9565 return true;
9566
9567 return false;
9568 }
9569
9571 int GetMuzzleID()
9572 {
9573 if (!m_WeaponTypeToID)
9575
9576 if (m_WeaponTypeToID.Contains(GetType()))
9577 {
9578 return m_WeaponTypeToID.Get(GetType());
9579 }
9580 else
9581 {
9582 // Register new weapon ID
9584 }
9585
9587 }
9588
9595 {
9596 return -1;
9597 }
9598
9599
9600
9601 // -------------------------------------------------------------------------
9602 void ~ItemBase()
9603 {
9604 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
9605 {
9606 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9607 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9608
9609 if (r_index >= 0)
9610 {
9611 InventoryLocation r_il = new InventoryLocation;
9612 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9613
9614 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9615 int r_type = r_il.GetType();
9616 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9617 {
9618 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9619 }
9620 else if (r_type == InventoryLocationType.ATTACHMENT)
9621 {
9622 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9623 }
9624
9625 }
9626
9627 player.GetHumanInventory().ClearUserReservedLocation(this);
9628 }
9629
9630 if (m_LockingSound)
9631 SEffectManager.DestroyEffect(m_LockingSound);
9632 }
9633
9634
9635
9636 // -------------------------------------------------------------------------
9637 static int GetDebugActionsMask()
9638 {
9639 return ItemBase.m_DebugActionsMask;
9640 }
9641
9642 static bool HasDebugActionsMask(int mask)
9643 {
9644 return ItemBase.m_DebugActionsMask & mask;
9645 }
9646
9647 static void SetDebugActionsMask(int mask)
9648 {
9649 ItemBase.m_DebugActionsMask = mask;
9650 }
9651
9652 static void AddDebugActionsMask(int mask)
9653 {
9654 ItemBase.m_DebugActionsMask |= mask;
9655 }
9656
9657 static void RemoveDebugActionsMask(int mask)
9658 {
9659 ItemBase.m_DebugActionsMask &= ~mask;
9660 }
9661
9662 static void ToggleDebugActionsMask(int mask)
9663 {
9664 if (HasDebugActionsMask(mask))
9665 {
9667 }
9668 else
9669 {
9670 AddDebugActionsMask(mask);
9671 }
9672 }
9673
9674 // -------------------------------------------------------------------------
9675 void SetCEBasedQuantity()
9676 {
9677 if (GetEconomyProfile())
9678 {
9679 float q_max = GetEconomyProfile().GetQuantityMax();
9680 if (q_max > 0)
9681 {
9682 float q_min = GetEconomyProfile().GetQuantityMin();
9683 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9684
9685 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9686 {
9687 ComponentEnergyManager comp = GetCompEM();
9688 if (comp && (comp.GetEnergyMaxPristine() || comp.GetEnergyAtSpawn()))//checking for a potential for energy, we need to check both values, as both are optional, only when both are set to 0, we know the item can't have energy
9689 {
9690 comp.SetEnergy0To1(quantity_randomized);
9691 }
9692 }
9693 else if (HasQuantity())
9694 {
9695 SetQuantityNormalized(quantity_randomized, false);
9696 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9697 }
9698
9699 }
9700 }
9701 }
9702
9704 void LockToParent()
9705 {
9706 EntityAI parent = GetHierarchyParent();
9707
9708 if (parent)
9709 {
9710 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9711 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9712 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9713 }
9714 }
9715
9717 void UnlockFromParent()
9718 {
9719 EntityAI parent = GetHierarchyParent();
9720
9721 if (parent)
9722 {
9723 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9724 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9725 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9726 }
9727 }
9728
9729 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9730 {
9731 /*
9732 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9733 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
9734 */
9735 ItemBase item2 = ItemBase.Cast(entity2);
9736
9737 if (GetGame().IsClient())
9738 {
9739 if (ScriptInputUserData.CanStoreInputUserData())
9740 {
9741 ScriptInputUserData ctx = new ScriptInputUserData;
9743 ctx.Write(-1);
9744 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9745 ctx.Write(i1);
9746 ctx.Write(item2);
9747 ctx.Write(use_stack_max);
9748 ctx.Write(-1);
9749 ctx.Send();
9750
9751 if (IsCombineAll(item2, use_stack_max))
9752 {
9753 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9754 }
9755 }
9756 }
9757 else if (!GetGame().IsMultiplayer())
9758 {
9759 CombineItems(item2, use_stack_max);
9760 }
9761 }
9762
9763 bool IsLiquidPresent()
9764 {
9765 return (GetLiquidType() != 0 && HasQuantity());
9766 }
9767
9768 bool IsLiquidContainer()
9769 {
9770 return m_LiquidContainerMask != 0;
9771 }
9772
9774 {
9775 return m_LiquidContainerMask;
9776 }
9777
9778 bool IsBloodContainer()
9779 {
9780 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9781 return false;
9782 }
9783
9784 bool IsNVG()
9785 {
9786 return false;
9787 }
9788
9791 bool IsExplosive()
9792 {
9793 return false;
9794 }
9795
9797 {
9798 return "";
9799 }
9800
9802
9803 bool IsLightSource()
9804 {
9805 return false;
9806 }
9807
9809 {
9810 return true;
9811 }
9812
9813 //--- ACTION CONDITIONS
9814 //direction
9815 bool IsFacingPlayer(PlayerBase player, string selection)
9816 {
9817 return true;
9818 }
9819
9820 bool IsPlayerInside(PlayerBase player, string selection)
9821 {
9822 return true;
9823 }
9824
9825 override bool CanObstruct()
9826 {
9827 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9828 return !player || !IsPlayerInside(player, "");
9829 }
9830
9831 override bool IsBeingPlaced()
9832 {
9833 return m_IsBeingPlaced;
9834 }
9835
9836 void SetIsBeingPlaced(bool is_being_placed)
9837 {
9838 m_IsBeingPlaced = is_being_placed;
9839 if (!is_being_placed)
9841 SetSynchDirty();
9842 }
9843
9844 //server-side
9845 void OnEndPlacement() {}
9846
9847 override bool IsHologram()
9848 {
9849 return m_IsHologram;
9850 }
9851
9852 bool CanBeDigged()
9853 {
9854 return m_CanBeDigged;
9855 }
9856
9858 {
9859 return 1;
9860 }
9861
9862 bool CanMakeGardenplot()
9863 {
9864 return false;
9865 }
9866
9867 void SetIsHologram(bool is_hologram)
9868 {
9869 m_IsHologram = is_hologram;
9870 SetSynchDirty();
9871 }
9872 /*
9873 protected float GetNutritionalEnergy()
9874 {
9875 Edible_Base edible = Edible_Base.Cast(this);
9876 return edible.GetFoodEnergy();
9877 }
9878
9879 protected float GetNutritionalWaterContent()
9880 {
9881 Edible_Base edible = Edible_Base.Cast(this);
9882 return edible.GetFoodWater();
9883 }
9884
9885 protected float GetNutritionalIndex()
9886 {
9887 Edible_Base edible = Edible_Base.Cast(this);
9888 return edible.GetFoodNutritionalIndex();
9889 }
9890
9891 protected float GetNutritionalFullnessIndex()
9892 {
9893 Edible_Base edible = Edible_Base.Cast(this);
9894 return edible.GetFoodTotalVolume();
9895 }
9896
9897 protected float GetNutritionalToxicity()
9898 {
9899 Edible_Base edible = Edible_Base.Cast(this);
9900 return edible.GetFoodToxicity();
9901
9902 }
9903 */
9904
9905
9906 // -------------------------------------------------------------------------
9907 override void OnMovedInsideCargo(EntityAI container)
9908 {
9909 super.OnMovedInsideCargo(container);
9910
9911 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9912 }
9913
9914 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9915 {
9916 super.EEItemLocationChanged(oldLoc,newLoc);
9917
9918 PlayerBase new_player = null;
9919 PlayerBase old_player = null;
9920
9921 if (newLoc.GetParent())
9922 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9923
9924 if (oldLoc.GetParent())
9925 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9926
9927 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
9928 {
9929 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
9930
9931 if (r_index >= 0)
9932 {
9933 InventoryLocation r_il = new InventoryLocation;
9934 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9935
9936 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9937 int r_type = r_il.GetType();
9938 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9939 {
9940 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9941 }
9942 else if (r_type == InventoryLocationType.ATTACHMENT)
9943 {
9944 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9945 }
9946
9947 }
9948 }
9949
9950 if (newLoc.GetType() == InventoryLocationType.HANDS)
9951 {
9952 if (new_player)
9953 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
9954
9955 if (new_player == old_player)
9956 {
9957
9958 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9959 {
9960 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9961 {
9962 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9963 {
9964 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9965 }
9966 }
9967 else
9968 {
9969 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9970 }
9971 }
9972
9973 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9974 {
9975 int type = oldLoc.GetType();
9976 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9977 {
9978 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9979 }
9980 else if (type == InventoryLocationType.ATTACHMENT)
9981 {
9982 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9983 }
9984 }
9985 if (!m_OldLocation)
9986 {
9987 m_OldLocation = new InventoryLocation;
9988 }
9989 m_OldLocation.Copy(oldLoc);
9990 }
9991 else
9992 {
9993 if (m_OldLocation)
9994 {
9995 m_OldLocation.Reset();
9996 }
9997 }
9998
10000 }
10001 else
10002 {
10003 if (new_player)
10004 {
10005 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
10006 if (res_index >= 0)
10007 {
10008 InventoryLocation il = new InventoryLocation;
10009 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
10010 ItemBase it = ItemBase.Cast(il.GetItem());
10011 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
10012 int rel_type = il.GetType();
10013 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
10014 {
10015 il.GetParent().GetOnReleaseLock().Invoke(it);
10016 }
10017 else if (rel_type == InventoryLocationType.ATTACHMENT)
10018 {
10019 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
10020 }
10021 //it.GetOnReleaseLock().Invoke(it);
10022 }
10023 }
10024 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
10025 {
10026 //ThrowPhysically(old_player, vector.Zero);
10027 m_ThrowItemOnDrop = false;
10028 }
10029
10030 if (m_OldLocation)
10031 {
10032 m_OldLocation.Reset();
10033 }
10034 }
10035 }
10036
10037 override void EOnContact(IEntity other, Contact extra)
10038 {
10040 {
10041 int liquidType = -1;
10042 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
10043 if (impactSpeed > 0.0)
10044 {
10045 m_ImpactSpeed = impactSpeed;
10046 #ifndef SERVER
10047 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10048 #else
10049 m_WantPlayImpactSound = true;
10050 SetSynchDirty();
10051 #endif
10052 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
10053 }
10054 }
10055
10056 #ifdef SERVER
10057 if (GetCompEM() && GetCompEM().IsPlugged())
10058 {
10059 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
10060 GetCompEM().UnplugThis();
10061 }
10062 #endif
10063 }
10064
10065 void RefreshPhysics();
10066
10067 override void OnCreatePhysics()
10068 {
10070 }
10071
10072 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10073 {
10074
10075 }
10076 // -------------------------------------------------------------------------
10077 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
10078 {
10079 super.OnItemLocationChanged(old_owner, new_owner);
10080
10081 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
10082 PlayerBase playerNew = PlayerBase.Cast(new_owner);
10083
10084 if (!relatedPlayer && playerNew)
10085 relatedPlayer = playerNew;
10086
10087 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
10088 {
10089 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
10090 if (actionMgr)
10091 {
10092 ActionBase currentAction = actionMgr.GetRunningAction();
10093 if (currentAction)
10094 currentAction.OnItemLocationChanged(this);
10095 }
10096 }
10097
10098 Man ownerPlayerOld = null;
10099 Man ownerPlayerNew = null;
10100
10101 if (old_owner)
10102 {
10103 if (old_owner.IsMan())
10104 {
10105 ownerPlayerOld = Man.Cast(old_owner);
10106 }
10107 else
10108 {
10109 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
10110 }
10111 }
10112 else
10113 {
10114 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
10115 {
10116 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
10117
10118 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
10119 {
10120 GetCompEM().UnplugThis();
10121 }
10122 }
10123 }
10124
10125 if (new_owner)
10126 {
10127 if (new_owner.IsMan())
10128 {
10129 ownerPlayerNew = Man.Cast(new_owner);
10130 }
10131 else
10132 {
10133 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
10134 }
10135 }
10136
10137 if (ownerPlayerOld != ownerPlayerNew)
10138 {
10139 if (ownerPlayerOld)
10140 {
10141 array<EntityAI> subItemsExit = new array<EntityAI>;
10142 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
10143 for (int i = 0; i < subItemsExit.Count(); i++)
10144 {
10145 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
10146 itemExit.OnInventoryExit(ownerPlayerOld);
10147 }
10148 }
10149
10150 if (ownerPlayerNew)
10151 {
10152 array<EntityAI> subItemsEnter = new array<EntityAI>;
10153 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
10154 for (int j = 0; j < subItemsEnter.Count(); j++)
10155 {
10156 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
10157 itemEnter.OnInventoryEnter(ownerPlayerNew);
10158 }
10159 }
10160 }
10161 else if (ownerPlayerNew != null)
10162 {
10163 PlayerBase nplayer;
10164 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
10165 {
10166 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10167 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10168 for (int k = 0; k < subItemsUpdate.Count(); k++)
10169 {
10170 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10171 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10172 }
10173 }
10174 }
10175
10176 if (old_owner)
10177 old_owner.OnChildItemRemoved(this);
10178 if (new_owner)
10179 new_owner.OnChildItemReceived(this);
10180 }
10181
10182 // -------------------------------------------------------------------------------
10183 override void EEDelete(EntityAI parent)
10184 {
10185 super.EEDelete(parent);
10186 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10187 if (player)
10188 {
10189 OnInventoryExit(player);
10190
10191 if (player.IsAlive())
10192 {
10193 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10194 if (r_index >= 0)
10195 {
10196 InventoryLocation r_il = new InventoryLocation;
10197 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10198
10199 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10200 int r_type = r_il.GetType();
10201 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10202 {
10203 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10204 }
10205 else if (r_type == InventoryLocationType.ATTACHMENT)
10206 {
10207 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10208 }
10209
10210 }
10211
10212 player.RemoveQuickBarEntityShortcut(this);
10213 }
10214 }
10215 }
10216 // -------------------------------------------------------------------------------
10217 override void EEKilled(Object killer)
10218 {
10219 super.EEKilled(killer);
10220
10222 if (killer && killer.IsFireplace() && CanExplodeInFire())
10223 {
10224 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
10225 {
10226 if (IsMagazine())
10227 {
10228 if (Magazine.Cast(this).GetAmmoCount() > 0)
10229 {
10230 ExplodeAmmo();
10231 }
10232 }
10233 else
10234 {
10235 Explode(DamageType.EXPLOSION);
10236 }
10237 }
10238 }
10239 }
10240
10241 override void OnWasAttached(EntityAI parent, int slot_id)
10242 {
10243 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10244
10245 super.OnWasAttached(parent, slot_id);
10246
10247 if (HasQuantity())
10248 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10249
10250 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
10251 }
10252
10253 override void OnWasDetached(EntityAI parent, int slot_id)
10254 {
10255 super.OnWasDetached(parent, slot_id);
10256
10257 if (HasQuantity())
10258 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10259 }
10260
10261 override string ChangeIntoOnAttach(string slot)
10262 {
10263 int idx;
10264 TStringArray inventory_slots = new TStringArray;
10265 TStringArray attach_types = new TStringArray;
10266
10267 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10268 if (inventory_slots.Count() < 1) //is string
10269 {
10270 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10271 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10272 }
10273 else //is array
10274 {
10275 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10276 }
10277
10278 idx = inventory_slots.Find(slot);
10279 if (idx < 0)
10280 return "";
10281
10282 return attach_types.Get(idx);
10283 }
10284
10285 override string ChangeIntoOnDetach()
10286 {
10287 int idx = -1;
10288 string slot;
10289
10290 TStringArray inventory_slots = new TStringArray;
10291 TStringArray detach_types = new TStringArray;
10292
10293 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10294 if (inventory_slots.Count() < 1) //is string
10295 {
10296 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10297 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10298 }
10299 else //is array
10300 {
10301 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10302 if (detach_types.Count() < 1)
10303 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10304 }
10305
10306 for (int i = 0; i < inventory_slots.Count(); i++)
10307 {
10308 slot = inventory_slots.Get(i);
10309 }
10310
10311 if (slot != "")
10312 {
10313 if (detach_types.Count() == 1)
10314 idx = 0;
10315 else
10316 idx = inventory_slots.Find(slot);
10317 }
10318 if (idx < 0)
10319 return "";
10320
10321 return detach_types.Get(idx);
10322 }
10323
10324 void ExplodeAmmo()
10325 {
10326 //timer
10327 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10328
10329 //min/max time
10330 float min_time = 1;
10331 float max_time = 3;
10332 float delay = Math.RandomFloat(min_time, max_time);
10333
10334 explode_timer.Run(delay, this, "DoAmmoExplosion");
10335 }
10336
10337 void DoAmmoExplosion()
10338 {
10339 Magazine magazine = Magazine.Cast(this);
10340 int pop_sounds_count = 6;
10341 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10342
10343 //play sound
10344 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10345 string sound_name = pop_sounds[ sound_idx ];
10346 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
10347
10348 //remove ammo count
10349 magazine.ServerAddAmmoCount(-1);
10350
10351 //if condition then repeat -> ExplodeAmmo
10352 float min_temp_to_explode = 100; //min temperature for item to explode
10353
10354 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10355 {
10356 ExplodeAmmo();
10357 }
10358 }
10359
10360 // -------------------------------------------------------------------------------
10361 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10362 {
10363 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10364
10365 const int CHANCE_DAMAGE_CARGO = 4;
10366 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10367 const int CHANCE_DAMAGE_NOTHING = 2;
10368
10369 if (IsClothing() || IsContainer() || IsItemTent())
10370 {
10371 float dmg = damageResult.GetDamage("","Health") * -0.5;
10372 int chances;
10373 int rnd;
10374
10375 if (GetInventory().GetCargo())
10376 {
10377 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10378 rnd = Math.RandomInt(0,chances);
10379
10380 if (rnd < CHANCE_DAMAGE_CARGO)
10381 {
10382 DamageItemInCargo(dmg);
10383 }
10384 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10385 {
10387 }
10388 }
10389 else
10390 {
10391 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10392 rnd = Math.RandomInt(0,chances);
10393
10394 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10395 {
10397 }
10398 }
10399 }
10400 }
10401
10402 bool DamageItemInCargo(float damage)
10403 {
10404 if (GetInventory().GetCargo())
10405 {
10406 int item_count = GetInventory().GetCargo().GetItemCount();
10407 if (item_count > 0)
10408 {
10409 int random_pick = Math.RandomInt(0, item_count);
10410 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
10411 if (!item.IsExplosive())
10412 {
10413 item.AddHealth("","",damage);
10414 return true;
10415 }
10416 }
10417 }
10418 return false;
10419 }
10420
10421 bool DamageItemAttachments(float damage)
10422 {
10423 int attachment_count = GetInventory().AttachmentCount();
10424 if (attachment_count > 0)
10425 {
10426 int random_pick = Math.RandomInt(0, attachment_count);
10427 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
10428 if (!attachment.IsExplosive())
10429 {
10430 attachment.AddHealth("","",damage);
10431 return true;
10432 }
10433 }
10434 return false;
10435 }
10436
10437 override bool IsSplitable()
10438 {
10439 return m_CanThisBeSplit;
10440 }
10441 //----------------
10442 override bool CanBeSplit()
10443 {
10444 if (IsSplitable() && (GetQuantity() > 1))
10445 return GetInventory().CanRemoveEntity();
10446
10447 return false;
10448 }
10449
10450 protected bool ShouldSplitQuantity(float quantity)
10451 {
10452 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10453 if (!IsSplitable())
10454 return false;
10455
10456 // nothing to split?
10457 if (GetQuantity() <= 1)
10458 return false;
10459
10460 // check if we should re-use the item instead of creating a new copy?
10461 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10462 int delta = GetQuantity() - quantity;
10463 if (delta == 0)
10464 return false;
10465
10466 // valid to split
10467 return true;
10468 }
10469
10470 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10471 {
10472 if (GetGame().IsClient())
10473 {
10474 if (ScriptInputUserData.CanStoreInputUserData())
10475 {
10476 ScriptInputUserData ctx = new ScriptInputUserData;
10478 ctx.Write(1);
10479 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10480 ctx.Write(i1);
10481 ctx.Write(destination_entity);
10482 ctx.Write(true);
10483 ctx.Write(slot_id);
10484 ctx.Send();
10485 }
10486 }
10487 else if (!GetGame().IsMultiplayer())
10488 {
10489 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
10490 }
10491 }
10492
10493 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10494 {
10495 float split_quantity_new;
10496 ItemBase new_item;
10497 float quantity = GetQuantity();
10498 float stack_max = GetTargetQuantityMax(slot_id);
10499 InventoryLocation loc = new InventoryLocation;
10500
10501 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10502 {
10503 if (stack_max <= GetQuantity())
10504 split_quantity_new = stack_max;
10505 else
10506 split_quantity_new = GetQuantity();
10507
10508 if (ShouldSplitQuantity(split_quantity_new))
10509 {
10510 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10511 if (new_item)
10512 {
10513 new_item.SetResultOfSplit(true);
10514 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10515 AddQuantity(-split_quantity_new, false, true);
10516 new_item.SetQuantity(split_quantity_new, false, true);
10517 }
10518 }
10519 }
10520 else if (destination_entity && slot_id == -1)
10521 {
10522 if (quantity > stack_max)
10523 split_quantity_new = stack_max;
10524 else
10525 split_quantity_new = quantity;
10526
10527 if (ShouldSplitQuantity(split_quantity_new))
10528 {
10529 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10530 {
10531 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10532 new_item = ItemBase.Cast(o);
10533 }
10534
10535 if (new_item)
10536 {
10537 new_item.SetResultOfSplit(true);
10538 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10539 AddQuantity(-split_quantity_new, false, true);
10540 new_item.SetQuantity(split_quantity_new, false, true);
10541 }
10542 }
10543 }
10544 else
10545 {
10546 if (stack_max != 0)
10547 {
10548 if (stack_max < GetQuantity())
10549 {
10550 split_quantity_new = GetQuantity() - stack_max;
10551 }
10552
10553 if (split_quantity_new == 0)
10554 {
10555 if (!GetGame().IsMultiplayer())
10556 player.PhysicalPredictiveDropItem(this);
10557 else
10558 player.ServerDropEntity(this);
10559 return;
10560 }
10561
10562 if (ShouldSplitQuantity(split_quantity_new))
10563 {
10564 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10565
10566 if (new_item)
10567 {
10568 new_item.SetResultOfSplit(true);
10569 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10570 SetQuantity(split_quantity_new, false, true);
10571 new_item.SetQuantity(stack_max, false, true);
10572 new_item.PlaceOnSurface();
10573 }
10574 }
10575 }
10576 }
10577 }
10578
10579 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10580 {
10581 float split_quantity_new;
10582 ItemBase new_item;
10583 float quantity = GetQuantity();
10584 float stack_max = GetTargetQuantityMax(slot_id);
10585 InventoryLocation loc = new InventoryLocation;
10586
10587 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10588 {
10589 if (stack_max <= GetQuantity())
10590 split_quantity_new = stack_max;
10591 else
10592 split_quantity_new = GetQuantity();
10593
10594 if (ShouldSplitQuantity(split_quantity_new))
10595 {
10596 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10597 if (new_item)
10598 {
10599 new_item.SetResultOfSplit(true);
10600 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10601 AddQuantity(-split_quantity_new, false, true);
10602 new_item.SetQuantity(split_quantity_new, false, true);
10603 }
10604 }
10605 }
10606 else if (destination_entity && slot_id == -1)
10607 {
10608 if (quantity > stack_max)
10609 split_quantity_new = stack_max;
10610 else
10611 split_quantity_new = quantity;
10612
10613 if (ShouldSplitQuantity(split_quantity_new))
10614 {
10615 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10616 {
10617 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10618 new_item = ItemBase.Cast(o);
10619 }
10620
10621 if (new_item)
10622 {
10623 new_item.SetResultOfSplit(true);
10624 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10625 AddQuantity(-split_quantity_new, false, true);
10626 new_item.SetQuantity(split_quantity_new, false, true);
10627 }
10628 }
10629 }
10630 else
10631 {
10632 if (stack_max != 0)
10633 {
10634 if (stack_max < GetQuantity())
10635 {
10636 split_quantity_new = GetQuantity() - stack_max;
10637 }
10638
10639 if (ShouldSplitQuantity(split_quantity_new))
10640 {
10641 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10642
10643 if (new_item)
10644 {
10645 new_item.SetResultOfSplit(true);
10646 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10647 SetQuantity(split_quantity_new, false, true);
10648 new_item.SetQuantity(stack_max, false, true);
10649 new_item.PlaceOnSurface();
10650 }
10651 }
10652 }
10653 }
10654 }
10655
10656 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10657 {
10658 if (GetGame().IsClient())
10659 {
10660 if (ScriptInputUserData.CanStoreInputUserData())
10661 {
10662 ScriptInputUserData ctx = new ScriptInputUserData;
10664 ctx.Write(4);
10665 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10666 ctx.Write(thiz);
10667 dst.WriteToContext(ctx);
10668 ctx.Send();
10669 }
10670 }
10671 else if (!GetGame().IsMultiplayer())
10672 {
10674 }
10675 }
10676
10677 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10678 {
10679 if (GetGame().IsClient())
10680 {
10681 if (ScriptInputUserData.CanStoreInputUserData())
10682 {
10683 ScriptInputUserData ctx = new ScriptInputUserData;
10685 ctx.Write(2);
10686 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10687 ctx.Write(dummy);
10688 ctx.Write(destination_entity);
10689 ctx.Write(true);
10690 ctx.Write(idx);
10691 ctx.Write(row);
10692 ctx.Write(col);
10693 ctx.Send();
10694 }
10695 }
10696 else if (!GetGame().IsMultiplayer())
10697 {
10698 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10699 }
10700 }
10701
10702 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10703 {
10705 }
10706
10707 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10708 {
10709 float quantity = GetQuantity();
10710 float split_quantity_new;
10711 ItemBase new_item;
10712 if (dst.IsValid())
10713 {
10714 int slot_id = dst.GetSlot();
10715 float stack_max = GetTargetQuantityMax(slot_id);
10716
10717 if (quantity > stack_max)
10718 split_quantity_new = stack_max;
10719 else
10720 split_quantity_new = quantity;
10721
10722 if (ShouldSplitQuantity(split_quantity_new))
10723 {
10724 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10725
10726 if (new_item)
10727 {
10728 new_item.SetResultOfSplit(true);
10729 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10730 AddQuantity(-split_quantity_new, false, true);
10731 new_item.SetQuantity(split_quantity_new, false, true);
10732 }
10733
10734 return new_item;
10735 }
10736 }
10737
10738 return null;
10739 }
10740
10741 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10742 {
10743 float quantity = GetQuantity();
10744 float split_quantity_new;
10745 ItemBase new_item;
10746 if (destination_entity)
10747 {
10748 float stackable = GetTargetQuantityMax();
10749 if (quantity > stackable)
10750 split_quantity_new = stackable;
10751 else
10752 split_quantity_new = quantity;
10753
10754 if (ShouldSplitQuantity(split_quantity_new))
10755 {
10756 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10757 if (new_item)
10758 {
10759 new_item.SetResultOfSplit(true);
10760 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10761 AddQuantity(-split_quantity_new, false, true);
10762 new_item.SetQuantity(split_quantity_new, false, true);
10763 }
10764 }
10765 }
10766 }
10767
10768 void SplitIntoStackMaxHandsClient(PlayerBase player)
10769 {
10770 if (GetGame().IsClient())
10771 {
10772 if (ScriptInputUserData.CanStoreInputUserData())
10773 {
10774 ScriptInputUserData ctx = new ScriptInputUserData;
10776 ctx.Write(3);
10777 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10778 ctx.Write(i1);
10779 ItemBase destination_entity = this;
10780 ctx.Write(destination_entity);
10781 ctx.Write(true);
10782 ctx.Write(0);
10783 ctx.Send();
10784 }
10785 }
10786 else if (!GetGame().IsMultiplayer())
10787 {
10788 SplitIntoStackMaxHands(player);
10789 }
10790 }
10791
10792 void SplitIntoStackMaxHands(PlayerBase player)
10793 {
10794 float quantity = GetQuantity();
10795 float split_quantity_new;
10796 ref ItemBase new_item;
10797 if (player)
10798 {
10799 float stackable = GetTargetQuantityMax();
10800 if (quantity > stackable)
10801 split_quantity_new = stackable;
10802 else
10803 split_quantity_new = quantity;
10804
10805 if (ShouldSplitQuantity(split_quantity_new))
10806 {
10807 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10808 new_item = ItemBase.Cast(in_hands);
10809 if (new_item)
10810 {
10811 new_item.SetResultOfSplit(true);
10812 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10813 AddQuantity(-split_quantity_new, false, true);
10814 new_item.SetQuantity(split_quantity_new, false, true);
10815 }
10816 }
10817 }
10818 }
10819
10820 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10821 {
10822 float quantity = GetQuantity();
10823 float split_quantity_new = Math.Floor(quantity * 0.5);
10824
10825 if (!ShouldSplitQuantity(split_quantity_new))
10826 return;
10827
10828 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10829
10830 if (new_item)
10831 {
10832 if (new_item.GetQuantityMax() < split_quantity_new)
10833 {
10834 split_quantity_new = new_item.GetQuantityMax();
10835 }
10836
10837 new_item.SetResultOfSplit(true);
10838 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10839
10840 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10841 {
10842 AddQuantity(-1, false, true);
10843 new_item.SetQuantity(1, false, true);
10844 }
10845 else
10846 {
10847 AddQuantity(-split_quantity_new, false, true);
10848 new_item.SetQuantity(split_quantity_new, false, true);
10849 }
10850 }
10851 }
10852
10853 void SplitItem(PlayerBase player)
10854 {
10855 float quantity = GetQuantity();
10856 float split_quantity_new = Math.Floor(quantity / 2);
10857
10858 if (!ShouldSplitQuantity(split_quantity_new))
10859 return;
10860
10861 InventoryLocation invloc = new InventoryLocation;
10862 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10863
10864 ItemBase new_item;
10865 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10866
10867 if (new_item)
10868 {
10869 if (new_item.GetQuantityMax() < split_quantity_new)
10870 {
10871 split_quantity_new = new_item.GetQuantityMax();
10872 }
10873 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10874 {
10875 AddQuantity(-1, false, true);
10876 new_item.SetQuantity(1, false, true);
10877 }
10878 else if (split_quantity_new > 1)
10879 {
10880 AddQuantity(-split_quantity_new, false, true);
10881 new_item.SetQuantity(split_quantity_new, false, true);
10882 }
10883 }
10884 }
10885
10887 void OnQuantityChanged(float delta)
10888 {
10889 SetWeightDirty();
10890 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10891
10892 if (parent)
10893 parent.OnAttachmentQuantityChangedEx(this, delta);
10894
10895 if (IsLiquidContainer())
10896 {
10897 if (GetQuantityNormalized() <= 0.0)
10898 {
10900 }
10901 else if (GetLiquidType() == LIQUID_NONE)
10902 {
10903 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10905 }
10906 }
10907
10908 }
10909
10912 {
10913 // insert code here
10914 }
10915
10917 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10918 {
10920 }
10921
10922 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10923 {
10924 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10925
10926 if (GetGame().IsServer())
10927 {
10928 if (newLevel == GameConstants.STATE_RUINED)
10929 {
10931 EntityAI parent = GetHierarchyParent();
10932 if (parent && parent.IsFireplace())
10933 {
10934 CargoBase cargo = GetInventory().GetCargo();
10935 if (cargo)
10936 {
10937 for (int i = 0; i < cargo.GetItemCount(); ++i)
10938 {
10939 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10940 }
10941 }
10942 }
10943 }
10944
10945 if (IsResultOfSplit())
10946 {
10947 // reset the splitting result flag, return to normal item behavior
10948 SetResultOfSplit(false);
10949 return;
10950 }
10951
10952 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10953 {
10954 SetCleanness(0);//unclean the item upon damage dealt
10955 }
10956 }
10957 }
10958
10959 // just the split? TODO: verify
10960 override void OnRightClick()
10961 {
10962 super.OnRightClick();
10963
10964 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
10965 {
10966 if (GetGame().IsClient())
10967 {
10968 if (ScriptInputUserData.CanStoreInputUserData())
10969 {
10970 EntityAI root = GetHierarchyRoot();
10971 Man playerOwner = GetHierarchyRootPlayer();
10972 InventoryLocation dst = new InventoryLocation;
10973
10974 // If we have no hierarchy root player and the root is the same as this item the source item is in the vicinity so we want to create the new split item there also
10975 if (!playerOwner && root && root == this)
10976 {
10978 }
10979 else
10980 {
10981 // Check if we can place the new split item in the same parent where the source item is placed in or otherwise drop it in vicinity
10982 GetInventory().GetCurrentInventoryLocation(dst);
10983 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10984 {
10985 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
10986 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10987 {
10989 }
10990 else
10991 {
10992 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10993 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10994 this shouldnt cause issues within this scope*/
10995 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10996 {
10998 }
10999 else
11000 {
11001 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
11002 }
11003 }
11004 }
11005 }
11006
11007 ScriptInputUserData ctx = new ScriptInputUserData;
11009 ctx.Write(4);
11010 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11011 ctx.Write(thiz);
11012 dst.WriteToContext(ctx);
11013 ctx.Write(true); // dummy
11014 ctx.Send();
11015 }
11016 }
11017 else if (!GetGame().IsMultiplayer())
11018 {
11019 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
11020 }
11021 }
11022 }
11023
11024 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
11025 {
11026 if (root)
11027 {
11028 vector m4[4];
11029 root.GetTransform(m4);
11030 dst.SetGround(this, m4);
11031 }
11032 else
11033 {
11034 GetInventory().GetCurrentInventoryLocation(dst);
11035 }
11036 }
11037
11038 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
11039 {
11040 //TODO: delete check zero quantity check after fix double posts hands fsm events
11041 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
11042 return false;
11043
11044 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
11045 return false;
11046
11047 //can_this_be_combined = ConfigGetBool("canBeSplit");
11049 return false;
11050
11051
11052 Magazine mag = Magazine.Cast(this);
11053 if (mag)
11054 {
11055 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
11056 return false;
11057
11058 if (stack_max_limit)
11059 {
11060 Magazine other_mag = Magazine.Cast(other_item);
11061 if (other_item)
11062 {
11063 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
11064 return false;
11065 }
11066
11067 }
11068 }
11069 else
11070 {
11071 //TODO: delete check zero quantity check after fix double posts hands fsm events
11072 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
11073 return false;
11074
11075 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
11076 return false;
11077 }
11078
11079 PlayerBase player = null;
11080 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
11081 {
11082 if (player.GetInventory().HasAttachment(this))
11083 return false;
11084
11085 if (player.IsItemsToDelete())
11086 return false;
11087 }
11088
11089 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
11090 return false;
11091
11092 int slotID;
11093 string slotName;
11094 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
11095 return false;
11096
11097 return true;
11098 }
11099
11100 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
11101 {
11102 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
11103 }
11104
11105 bool IsResultOfSplit()
11106 {
11107 return m_IsResultOfSplit;
11108 }
11109
11110 void SetResultOfSplit(bool value)
11111 {
11112 m_IsResultOfSplit = value;
11113 }
11114
11115 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
11116 {
11117 return ComputeQuantityUsedEx(other_item, use_stack_max);
11118 }
11119
11120 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
11121 {
11122 float other_item_quantity = other_item.GetQuantity();
11123 float this_free_space;
11124
11125 float stack_max = GetQuantityMax();
11126
11127 this_free_space = stack_max - GetQuantity();
11128
11129 if (other_item_quantity > this_free_space)
11130 {
11131 return this_free_space;
11132 }
11133 else
11134 {
11135 return other_item_quantity;
11136 }
11137 }
11138
11139 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
11140 {
11141 CombineItems(ItemBase.Cast(entity2),use_stack_max);
11142 }
11143
11144 void CombineItems(ItemBase other_item, bool use_stack_max = true)
11145 {
11146 if (!CanBeCombined(other_item, false))
11147 return;
11148
11149 if (!IsMagazine() && other_item)
11150 {
11151 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
11152 if (quantity_used != 0)
11153 {
11154 float hp1 = GetHealth01("","");
11155 float hp2 = other_item.GetHealth01("","");
11156 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
11157 hpResult = hpResult / (GetQuantity() + quantity_used);
11158
11159 hpResult *= GetMaxHealth();
11160 Math.Round(hpResult);
11161 SetHealth("", "Health", hpResult);
11162
11163 AddQuantity(quantity_used);
11164 other_item.AddQuantity(-quantity_used);
11165 }
11166 }
11167 OnCombine(other_item);
11168 }
11169
11170 void OnCombine(ItemBase other_item)
11171 {
11172 #ifdef SERVER
11173 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11174 GetHierarchyParent().IncreaseLifetimeUp();
11175 #endif
11176 };
11177
11178 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11179 {
11180 PlayerBase p = PlayerBase.Cast(player);
11181
11182 array<int> recipesIds = p.m_Recipes;
11183 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11184 if (moduleRecipesManager)
11185 {
11186 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
11187 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11188 }
11189
11190 for (int i = 0;i < recipesIds.Count(); i++)
11191 {
11192 int key = recipesIds.Get(i);
11193 string recipeName = moduleRecipesManager.GetRecipeName(key);
11194 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11195 }
11196 }
11197
11198 // -------------------------------------------------------------------------
11199 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11200 {
11201 super.GetDebugActions(outputList);
11202
11203 //quantity
11204 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11205 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11206 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11207 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11208 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11209
11210 //health
11211 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
11212 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
11213 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
11214 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11215 //temperature
11216 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
11217 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
11218 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
11219 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11220
11221 //wet
11222 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
11223 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
11224 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11225
11226 //liquidtype
11227 if (IsLiquidContainer())
11228 {
11229 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
11230 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
11231 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11232 }
11233
11234 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
11235 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11236
11237 // watch
11238 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
11239 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
11240 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11241
11242 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
11243
11244 InventoryLocation loc = new InventoryLocation();
11245 GetInventory().GetCurrentInventoryLocation(loc);
11246 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11247 {
11248 if (Gizmo_IsSupported())
11249 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11250 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11251 }
11252
11253 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11254 }
11255
11256 // -------------------------------------------------------------------------
11257 // -------------------------------------------------------------------------
11258 // -------------------------------------------------------------------------
11259 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11260 {
11261 super.OnAction(action_id, player, ctx);
11262
11263 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
11264 {
11265 switch (action_id)
11266 {
11267 case EActions.GIZMO_OBJECT:
11268 GetGame().GizmoSelectObject(this);
11269 return true;
11270 case EActions.GIZMO_PHYSICS:
11271 GetGame().GizmoSelectPhysics(GetPhysics());
11272 return true;
11273 }
11274 }
11275
11276 if (GetGame().IsServer())
11277 {
11278 switch (action_id)
11279 {
11280 case EActions.DELETE:
11281 Delete();
11282 return true;
11283 }
11284 }
11285
11286 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11287 {
11288 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11289 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11290 PlayerBase p = PlayerBase.Cast(player);
11291 if (EActions.RECIPES_RANGE_START < 1000)
11292 {
11293 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11294 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11295 }
11296 }
11297 #ifndef SERVER
11298 else if (action_id == EActions.WATCH_PLAYER)
11299 {
11300 PluginDeveloper.SetDeveloperItemClientEx(player);
11301 }
11302 #endif
11303 if (GetGame().IsServer())
11304 {
11305 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11306 {
11307 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11308 OnDebugButtonPressServer(id + 1);
11309 }
11310
11311 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11312 {
11313 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11314 InsertAgent(agent_id,100);
11315 }
11316
11317 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11318 {
11319 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11320 RemoveAgent(agent_id2);
11321 }
11322
11323 else if (action_id == EActions.ADD_QUANTITY)
11324 {
11325 if (IsMagazine())
11326 {
11327 Magazine mag = Magazine.Cast(this);
11328 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11329 }
11330 else
11331 {
11332 AddQuantity(GetQuantityMax() * 0.2);
11333 }
11334
11335 if (m_EM)
11336 {
11337 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11338 }
11339 //PrintVariables();
11340 }
11341
11342 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11343 {
11344 if (IsMagazine())
11345 {
11346 Magazine mag2 = Magazine.Cast(this);
11347 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11348 }
11349 else
11350 {
11351 AddQuantity(- GetQuantityMax() * 0.2);
11352 }
11353 if (m_EM)
11354 {
11355 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11356 }
11357 //PrintVariables();
11358 }
11359
11360 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11361 {
11362 SetQuantity(0);
11363
11364 if (m_EM)
11365 {
11366 m_EM.SetEnergy(0);
11367 }
11368 }
11369
11370 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11371 {
11373
11374 if (m_EM)
11375 {
11376 m_EM.SetEnergy(m_EM.GetEnergyMax());
11377 }
11378 }
11379
11380 else if (action_id == EActions.ADD_HEALTH)
11381 {
11382 AddHealth("","",GetMaxHealth("","Health")/5);
11383 }
11384 else if (action_id == EActions.REMOVE_HEALTH)
11385 {
11386 AddHealth("","",-GetMaxHealth("","Health")/5);
11387 }
11388 else if (action_id == EActions.DESTROY_HEALTH)
11389 {
11390 SetHealth01("","",0);
11391 }
11392 else if (action_id == EActions.WATCH_ITEM)
11393 {
11395 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11396 #ifdef DEVELOPER
11397 SetDebugDeveloper_item(this);
11398 #endif
11399 }
11400
11401 else if (action_id == EActions.ADD_TEMPERATURE)
11402 {
11403 AddTemperature(20);
11404 //PrintVariables();
11405 }
11406
11407 else if (action_id == EActions.REMOVE_TEMPERATURE)
11408 {
11409 AddTemperature(-20);
11410 //PrintVariables();
11411 }
11412
11413 else if (action_id == EActions.FLIP_FROZEN)
11414 {
11415 SetFrozen(!GetIsFrozen());
11416 //PrintVariables();
11417 }
11418
11419 else if (action_id == EActions.ADD_WETNESS)
11420 {
11421 AddWet(GetWetMax()/5);
11422 //PrintVariables();
11423 }
11424
11425 else if (action_id == EActions.REMOVE_WETNESS)
11426 {
11427 AddWet(-GetWetMax()/5);
11428 //PrintVariables();
11429 }
11430
11431 else if (action_id == EActions.LIQUIDTYPE_UP)
11432 {
11433 int curr_type = GetLiquidType();
11434 SetLiquidType(curr_type * 2);
11435 //AddWet(1);
11436 //PrintVariables();
11437 }
11438
11439 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11440 {
11441 int curr_type2 = GetLiquidType();
11442 SetLiquidType(curr_type2 / 2);
11443 }
11444
11445 else if (action_id == EActions.MAKE_SPECIAL)
11446 {
11447 auto debugParams = DebugSpawnParams.WithPlayer(player);
11448 OnDebugSpawnEx(debugParams);
11449 }
11450
11451 }
11452
11453
11454 return false;
11455 }
11456
11457 // -------------------------------------------------------------------------
11458
11459
11462 void OnActivatedByTripWire();
11463
11465 void OnActivatedByItem(notnull ItemBase item);
11466
11467 //----------------------------------------------------------------
11468 //returns true if item is able to explode when put in fire
11469 bool CanExplodeInFire()
11470 {
11471 return false;
11472 }
11473
11474 //----------------------------------------------------------------
11475 bool CanEat()
11476 {
11477 return true;
11478 }
11479
11480 //----------------------------------------------------------------
11481 override bool IsIgnoredByConstruction()
11482 {
11483 return true;
11484 }
11485
11486 //----------------------------------------------------------------
11487 //has FoodStages in config?
11488 bool HasFoodStage()
11489 {
11490 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11491 return GetGame().ConfigIsExisting(config_path);
11492 }
11493
11495 FoodStage GetFoodStage()
11496 {
11497 return null;
11498 }
11499
11500 bool CanBeCooked()
11501 {
11502 return false;
11503 }
11504
11505 bool CanBeCookedOnStick()
11506 {
11507 return false;
11508 }
11509
11511 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11513
11514 //----------------------------------------------------------------
11515 bool CanRepair(ItemBase item_repair_kit)
11516 {
11517 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11518 return module_repairing.CanRepair(this, item_repair_kit);
11519 }
11520
11521 //----------------------------------------------------------------
11522 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11523 {
11524 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11525 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11526 }
11527
11528 //----------------------------------------------------------------
11529 int GetItemSize()
11530 {
11531 /*
11532 vector v_size = this.ConfigGetVector("itemSize");
11533 int v_size_x = v_size[0];
11534 int v_size_y = v_size[1];
11535 int size = v_size_x * v_size_y;
11536 return size;
11537 */
11538
11539 return 1;
11540 }
11541
11542 //----------------------------------------------------------------
11543 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11544 bool CanBeMovedOverride()
11545 {
11546 return m_CanBeMovedOverride;
11547 }
11548
11549 //----------------------------------------------------------------
11550 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11551 void SetCanBeMovedOverride(bool setting)
11552 {
11553 m_CanBeMovedOverride = setting;
11554 }
11555
11556 //----------------------------------------------------------------
11564 void MessageToOwnerStatus(string text)
11565 {
11566 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11567
11568 if (player)
11569 {
11570 player.MessageStatus(text);
11571 }
11572 }
11573
11574 //----------------------------------------------------------------
11582 void MessageToOwnerAction(string text)
11583 {
11584 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11585
11586 if (player)
11587 {
11588 player.MessageAction(text);
11589 }
11590 }
11591
11592 //----------------------------------------------------------------
11600 void MessageToOwnerFriendly(string text)
11601 {
11602 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11603
11604 if (player)
11605 {
11606 player.MessageFriendly(text);
11607 }
11608 }
11609
11610 //----------------------------------------------------------------
11618 void MessageToOwnerImportant(string text)
11619 {
11620 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11621
11622 if (player)
11623 {
11624 player.MessageImportant(text);
11625 }
11626 }
11627
11628 override bool IsItemBase()
11629 {
11630 return true;
11631 }
11632
11633 // Checks if item is of questioned kind
11634 override bool KindOf(string tag)
11635 {
11636 bool found = false;
11637 string item_name = this.GetType();
11638 ref TStringArray item_tag_array = new TStringArray;
11639 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11640
11641 int array_size = item_tag_array.Count();
11642 for (int i = 0; i < array_size; i++)
11643 {
11644 if (item_tag_array.Get(i) == tag)
11645 {
11646 found = true;
11647 break;
11648 }
11649 }
11650 return found;
11651 }
11652
11653
11654 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11655 {
11656 //Debug.Log("OnRPC called");
11657 super.OnRPC(sender, rpc_type,ctx);
11658
11659 //Play soundset for attachment locking (ActionLockAttachment.c)
11660 switch (rpc_type)
11661 {
11662 #ifndef SERVER
11663 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11664 Param2<bool, string> p = new Param2<bool, string>(false, "");
11665
11666 if (!ctx.Read(p))
11667 return;
11668
11669 bool play = p.param1;
11670 string soundSet = p.param2;
11671
11672 if (play)
11673 {
11674 if (m_LockingSound)
11675 {
11677 {
11678 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11679 }
11680 }
11681 else
11682 {
11683 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11684 }
11685 }
11686 else
11687 {
11688 SEffectManager.DestroyEffect(m_LockingSound);
11689 }
11690
11691 break;
11692 #endif
11693
11694 }
11695
11696 if (GetWrittenNoteData())
11697 {
11698 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11699 }
11700 }
11701
11702 //-----------------------------
11703 // VARIABLE MANIPULATION SYSTEM
11704 //-----------------------------
11705 int NameToID(string name)
11706 {
11707 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11708 return plugin.GetID(name);
11709 }
11710
11711 string IDToName(int id)
11712 {
11713 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11714 return plugin.GetName(id);
11715 }
11716
11718 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11719 {
11720 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11721 //read the flags
11722 int varFlags;
11723 if (!ctx.Read(varFlags))
11724 return;
11725
11726 if (varFlags & ItemVariableFlags.FLOAT)
11727 {
11728 ReadVarsFromCTX(ctx);
11729 }
11730 }
11731
11732 override void SerializeNumericalVars(array<float> floats_out)
11733 {
11734 //some variables handled on EntityAI level already!
11735 super.SerializeNumericalVars(floats_out);
11736
11737 // the order of serialization must be the same as the order of de-serialization
11738 //--------------------------------------------
11739 if (IsVariableSet(VARIABLE_QUANTITY))
11740 {
11741 floats_out.Insert(m_VarQuantity);
11742 }
11743 //--------------------------------------------
11744 if (IsVariableSet(VARIABLE_WET))
11745 {
11746 floats_out.Insert(m_VarWet);
11747 }
11748 //--------------------------------------------
11749 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11750 {
11751 floats_out.Insert(m_VarLiquidType);
11752 }
11753 //--------------------------------------------
11754 if (IsVariableSet(VARIABLE_COLOR))
11755 {
11756 floats_out.Insert(m_ColorComponentR);
11757 floats_out.Insert(m_ColorComponentG);
11758 floats_out.Insert(m_ColorComponentB);
11759 floats_out.Insert(m_ColorComponentA);
11760 }
11761 //--------------------------------------------
11762 if (IsVariableSet(VARIABLE_CLEANNESS))
11763 {
11764 floats_out.Insert(m_Cleanness);
11765 }
11766 }
11767
11768 override void DeSerializeNumericalVars(array<float> floats)
11769 {
11770 //some variables handled on EntityAI level already!
11771 super.DeSerializeNumericalVars(floats);
11772
11773 // the order of serialization must be the same as the order of de-serialization
11774 int index = 0;
11775 int mask = Math.Round(floats.Get(index));
11776
11777 index++;
11778 //--------------------------------------------
11779 if (mask & VARIABLE_QUANTITY)
11780 {
11781 if (m_IsStoreLoad)
11782 {
11783 SetStoreLoadedQuantity(floats.Get(index));
11784 }
11785 else
11786 {
11787 float quantity = floats.Get(index);
11788 SetQuantity(quantity, true, false, false, false);
11789 }
11790 index++;
11791 }
11792 //--------------------------------------------
11793 if (mask & VARIABLE_WET)
11794 {
11795 float wet = floats.Get(index);
11796 SetWet(wet);
11797 index++;
11798 }
11799 //--------------------------------------------
11800 if (mask & VARIABLE_LIQUIDTYPE)
11801 {
11802 int liquidtype = Math.Round(floats.Get(index));
11803 SetLiquidType(liquidtype);
11804 index++;
11805 }
11806 //--------------------------------------------
11807 if (mask & VARIABLE_COLOR)
11808 {
11809 m_ColorComponentR = Math.Round(floats.Get(index));
11810 index++;
11811 m_ColorComponentG = Math.Round(floats.Get(index));
11812 index++;
11813 m_ColorComponentB = Math.Round(floats.Get(index));
11814 index++;
11815 m_ColorComponentA = Math.Round(floats.Get(index));
11816 index++;
11817 }
11818 //--------------------------------------------
11819 if (mask & VARIABLE_CLEANNESS)
11820 {
11821 int cleanness = Math.Round(floats.Get(index));
11822 SetCleanness(cleanness);
11823 index++;
11824 }
11825 }
11826
11827 override void WriteVarsToCTX(ParamsWriteContext ctx)
11828 {
11829 super.WriteVarsToCTX(ctx);
11830
11831 //--------------------------------------------
11832 if (IsVariableSet(VARIABLE_QUANTITY))
11833 {
11834 ctx.Write(GetQuantity());
11835 }
11836 //--------------------------------------------
11837 if (IsVariableSet(VARIABLE_WET))
11838 {
11839 ctx.Write(GetWet());
11840 }
11841 //--------------------------------------------
11842 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11843 {
11844 ctx.Write(GetLiquidType());
11845 }
11846 //--------------------------------------------
11847 if (IsVariableSet(VARIABLE_COLOR))
11848 {
11849 int r,g,b,a;
11850 GetColor(r,g,b,a);
11851 ctx.Write(r);
11852 ctx.Write(g);
11853 ctx.Write(b);
11854 ctx.Write(a);
11855 }
11856 //--------------------------------------------
11857 if (IsVariableSet(VARIABLE_CLEANNESS))
11858 {
11859 ctx.Write(GetCleanness());
11860 }
11861 }
11862
11863 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11864 {
11865 if (!super.ReadVarsFromCTX(ctx,version))
11866 return false;
11867
11868 int intValue;
11869 float value;
11870
11871 if (version < 140)
11872 {
11873 if (!ctx.Read(intValue))
11874 return false;
11875
11876 m_VariablesMask = intValue;
11877 }
11878
11879 if (m_VariablesMask & VARIABLE_QUANTITY)
11880 {
11881 if (!ctx.Read(value))
11882 return false;
11883
11884 if (IsStoreLoad())
11885 {
11887 }
11888 else
11889 {
11890 SetQuantity(value, true, false, false, false);
11891 }
11892 }
11893 //--------------------------------------------
11894 if (version < 140)
11895 {
11896 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11897 {
11898 if (!ctx.Read(value))
11899 return false;
11900 SetTemperatureDirect(value);
11901 }
11902 }
11903 //--------------------------------------------
11904 if (m_VariablesMask & VARIABLE_WET)
11905 {
11906 if (!ctx.Read(value))
11907 return false;
11908 SetWet(value);
11909 }
11910 //--------------------------------------------
11911 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11912 {
11913 if (!ctx.Read(intValue))
11914 return false;
11915 SetLiquidType(intValue);
11916 }
11917 //--------------------------------------------
11918 if (m_VariablesMask & VARIABLE_COLOR)
11919 {
11920 int r,g,b,a;
11921 if (!ctx.Read(r))
11922 return false;
11923 if (!ctx.Read(g))
11924 return false;
11925 if (!ctx.Read(b))
11926 return false;
11927 if (!ctx.Read(a))
11928 return false;
11929
11930 SetColor(r,g,b,a);
11931 }
11932 //--------------------------------------------
11933 if (m_VariablesMask & VARIABLE_CLEANNESS)
11934 {
11935 if (!ctx.Read(intValue))
11936 return false;
11937 SetCleanness(intValue);
11938 }
11939 //--------------------------------------------
11940 if (version >= 138 && version < 140)
11941 {
11942 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11943 {
11944 if (!ctx.Read(intValue))
11945 return false;
11946 SetFrozen(intValue);
11947 }
11948 }
11949
11950 return true;
11951 }
11952
11953 //----------------------------------------------------------------
11954 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11955 {
11956 m_IsStoreLoad = true;
11958 {
11959 m_FixDamageSystemInit = true;
11960 }
11961
11962 if (!super.OnStoreLoad(ctx, version))
11963 {
11964 m_IsStoreLoad = false;
11965 return false;
11966 }
11967
11968 if (version >= 114)
11969 {
11970 bool hasQuickBarIndexSaved;
11971
11972 if (!ctx.Read(hasQuickBarIndexSaved))
11973 {
11974 m_IsStoreLoad = false;
11975 return false;
11976 }
11977
11978 if (hasQuickBarIndexSaved)
11979 {
11980 int itmQBIndex;
11981
11982 //Load quickbar item bind
11983 if (!ctx.Read(itmQBIndex))
11984 {
11985 m_IsStoreLoad = false;
11986 return false;
11987 }
11988
11989 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11990 if (itmQBIndex != -1 && parentPlayer)
11991 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11992 }
11993 }
11994 else
11995 {
11996 // Backup of how it used to be
11997 PlayerBase player;
11998 int itemQBIndex;
11999 if (version == int.MAX)
12000 {
12001 if (!ctx.Read(itemQBIndex))
12002 {
12003 m_IsStoreLoad = false;
12004 return false;
12005 }
12006 }
12007 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
12008 {
12009 //Load quickbar item bind
12010 if (!ctx.Read(itemQBIndex))
12011 {
12012 m_IsStoreLoad = false;
12013 return false;
12014 }
12015 if (itemQBIndex != -1 && player)
12016 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
12017 }
12018 }
12019
12020 if (version < 140)
12021 {
12022 // variable management system
12023 if (!LoadVariables(ctx, version))
12024 {
12025 m_IsStoreLoad = false;
12026 return false;
12027 }
12028 }
12029
12030 //agent trasmission system
12031 if (!LoadAgents(ctx, version))
12032 {
12033 m_IsStoreLoad = false;
12034 return false;
12035 }
12036 if (version >= 132)
12037 {
12038 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12039 if (raib)
12040 {
12041 if (!raib.OnStoreLoad(ctx,version))
12042 {
12043 m_IsStoreLoad = false;
12044 return false;
12045 }
12046 }
12047 }
12048
12049 m_IsStoreLoad = false;
12050 return true;
12051 }
12052
12053 //----------------------------------------------------------------
12054
12055 override void OnStoreSave(ParamsWriteContext ctx)
12056 {
12057 super.OnStoreSave(ctx);
12058
12059 PlayerBase player;
12060 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
12061 {
12062 ctx.Write(true); // Keep track of if we should actually read this in or not
12063 //Save quickbar item bind
12064 int itemQBIndex = -1;
12065 itemQBIndex = player.FindQuickBarEntityIndex(this);
12066 ctx.Write(itemQBIndex);
12067 }
12068 else
12069 {
12070 ctx.Write(false); // Keep track of if we should actually read this in or not
12071 }
12072
12073 SaveAgents(ctx);//agent trasmission system
12074
12075 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12076 if (raib)
12077 {
12078 raib.OnStoreSave(ctx);
12079 }
12080 }
12081 //----------------------------------------------------------------
12082
12083 override void AfterStoreLoad()
12084 {
12085 super.AfterStoreLoad();
12086
12088 {
12090 }
12091
12092 if (GetStoreLoadedQuantity() != float.LOWEST)
12093 {
12095 SetStoreLoadedQuantity(float.LOWEST);//IMPORTANT to do this !! we use 'm_StoreLoadedQuantity' inside SetQuantity to distinguish between initial quantity setting and the consequent(normal gameplay) calls
12096 }
12097 }
12098
12099 override void EEOnAfterLoad()
12100 {
12101 super.EEOnAfterLoad();
12102
12104 {
12105 m_FixDamageSystemInit = false;
12106 }
12107
12110 }
12111
12112 bool CanBeDisinfected()
12113 {
12114 return false;
12115 }
12116
12117
12118 //----------------------------------------------------------------
12119 override void OnVariablesSynchronized()
12120 {
12121 if (m_Initialized)
12122 {
12123 #ifdef PLATFORM_CONSOLE
12124 //bruteforce it is
12125 if (IsSplitable())
12126 {
12127 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
12128 if (menu)
12129 {
12130 menu.Refresh();
12131 }
12132 }
12133 #endif
12134 }
12135
12137 {
12138 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
12139 m_WantPlayImpactSound = false;
12140 }
12141
12143 {
12144 SetWeightDirty();
12146 }
12147 if (m_VarWet != m_VarWetPrev)
12148 {
12151 }
12152
12153 if (m_SoundSyncPlay != 0)
12154 {
12155 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
12156 m_SoundSyncPlay = 0;
12157 }
12158 if (m_SoundSyncStop != 0)
12159 {
12160 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12161 m_SoundSyncStop = 0;
12162 }
12163
12164 super.OnVariablesSynchronized();
12165 }
12166
12167 //------------------------- Quantity
12168 //----------------------------------------------------------------
12170 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12171 {
12172 if (!IsServerCheck(allow_client))
12173 return false;
12174
12175 if (!HasQuantity())
12176 return false;
12177
12178 float min = GetQuantityMin();
12179 float max = GetQuantityMax();
12180
12181 if (value <= (min + 0.001))
12182 value = min;
12183
12184 if (value == min)
12185 {
12186 if (destroy_config)
12187 {
12188 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12189 if (dstr)
12190 {
12191 m_VarQuantity = Math.Clamp(value, min, max);
12192 this.Delete();
12193 return true;
12194 }
12195 }
12196 else if (destroy_forced)
12197 {
12198 m_VarQuantity = Math.Clamp(value, min, max);
12199 this.Delete();
12200 return true;
12201 }
12202 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12203 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12204 }
12205
12206 float delta = m_VarQuantity;
12207 m_VarQuantity = Math.Clamp(value, min, max);
12208
12209 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
12210 {
12211 delta = m_VarQuantity - delta;
12212
12213 if (delta)
12214 OnQuantityChanged(delta);
12215 }
12216
12217 SetVariableMask(VARIABLE_QUANTITY);
12218
12219 return false;
12220 }
12221
12222 //----------------------------------------------------------------
12224 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
12225 {
12226 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
12227 }
12228 //----------------------------------------------------------------
12229 void SetQuantityMax()
12230 {
12231 float max = GetQuantityMax();
12232 SetQuantity(max);
12233 }
12234
12235 override void SetQuantityToMinimum()
12236 {
12237 float min = GetQuantityMin();
12238 SetQuantity(min);
12239 }
12240 //----------------------------------------------------------------
12242 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
12243 {
12244 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
12245 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
12246 SetQuantity(result, destroy_config, destroy_forced);
12247 }
12248
12249 //----------------------------------------------------------------
12251 override float GetQuantityNormalized()
12252 {
12253 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12254 }
12255
12257 {
12258 return GetQuantityNormalized();
12259 }
12260
12261 /*void SetAmmoNormalized(float value)
12262 {
12263 float value_clamped = Math.Clamp(value, 0, 1);
12264 Magazine this_mag = Magazine.Cast(this);
12265 int max_rounds = this_mag.GetAmmoMax();
12266 int result = value * max_rounds;//can the rounded if higher precision is required
12267 this_mag.SetAmmoCount(result);
12268 }*/
12269 //----------------------------------------------------------------
12270 override int GetQuantityMax()
12271 {
12272 int slot = -1;
12273 if (GetInventory())
12274 {
12275 InventoryLocation il = new InventoryLocation;
12276 GetInventory().GetCurrentInventoryLocation(il);
12277 slot = il.GetSlot();
12278 }
12279
12280 return GetTargetQuantityMax(slot);
12281 }
12282
12283 override int GetTargetQuantityMax(int attSlotID = -1)
12284 {
12285 float quantity_max = 0;
12286
12287 if (IsSplitable()) //only stackable/splitable items can check for stack size
12288 {
12289 if (attSlotID != -1)
12290 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12291
12292 if (quantity_max <= 0)
12293 quantity_max = m_VarStackMax;
12294 }
12295
12296 if (quantity_max <= 0)
12297 quantity_max = m_VarQuantityMax;
12298
12299 return quantity_max;
12300 }
12301 //----------------------------------------------------------------
12302 override int GetQuantityMin()
12303 {
12304 return m_VarQuantityMin;
12305 }
12306 //----------------------------------------------------------------
12307 int GetQuantityInit()
12308 {
12309 return m_VarQuantityInit;
12310 }
12311
12312 //----------------------------------------------------------------
12313 override bool HasQuantity()
12314 {
12315 return !(GetQuantityMax() - GetQuantityMin() == 0);
12316 }
12317
12318 override float GetQuantity()
12319 {
12320 return m_VarQuantity;
12321 }
12322
12323 bool IsFullQuantity()
12324 {
12325 return GetQuantity() >= GetQuantityMax();
12326 }
12327
12328 //Calculates weight of single item without attachments and cargo
12329 override float GetSingleInventoryItemWeightEx()
12330 {
12331 //this needs to be first stored inside local variables, when returned directly during inside return call, the result is completely different due to enforce script bug
12332 float weightEx = GetWeightEx();//overall weight of the item
12333 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12334 return weightEx - special;
12335 }
12336
12337 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12339 {
12341 }
12342
12343 override protected float GetWeightSpecialized(bool forceRecalc = false)
12344 {
12345 if (IsSplitable()) //quantity determines size of the stack
12346 {
12347 #ifdef DEVELOPER
12348 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12349 {
12350 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12351 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12352 }
12353 #endif
12354
12355 return GetQuantity() * GetConfigWeightModified();
12356 }
12357 else if (HasEnergyManager())// items with energy manager
12358 {
12359 #ifdef DEVELOPER
12360 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12361 {
12362 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12363 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12364 }
12365 #endif
12366 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12367 }
12368 else//everything else
12369 {
12370 #ifdef DEVELOPER
12371 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12372 {
12373 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12374 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12375 }
12376 #endif
12377 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12378 }
12379 }
12380
12382 int GetNumberOfItems()
12383 {
12384 int item_count = 0;
12385 ItemBase item;
12386
12387 if (GetInventory().GetCargo() != NULL)
12388 {
12389 item_count = GetInventory().GetCargo().GetItemCount();
12390 }
12391
12392 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
12393 {
12394 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
12395 if (item)
12396 item_count += item.GetNumberOfItems();
12397 }
12398 return item_count;
12399 }
12400
12402 float GetUnitWeight(bool include_wetness = true)
12403 {
12404 float weight = 0;
12405 float wetness = 1;
12406 if (include_wetness)
12407 wetness += GetWet();
12408 if (IsSplitable()) //quantity determines size of the stack
12409 {
12410 weight = wetness * m_ConfigWeight;
12411 }
12412 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12413 {
12414 weight = 1;
12415 }
12416 return weight;
12417 }
12418
12419 //-----------------------------------------------------------------
12420
12421 override void ClearInventory()
12422 {
12423 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
12424 {
12425 GameInventory inv = GetInventory();
12426 array<EntityAI> items = new array<EntityAI>;
12427 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
12428 for (int i = 0; i < items.Count(); i++)
12429 {
12430 ItemBase item = ItemBase.Cast(items.Get(i));
12431 if (item)
12432 {
12433 GetGame().ObjectDelete(item);
12434 }
12435 }
12436 }
12437 }
12438
12439 //------------------------- Energy
12440
12441 //----------------------------------------------------------------
12442 float GetEnergy()
12443 {
12444 float energy = 0;
12445 if (HasEnergyManager())
12446 {
12447 energy = GetCompEM().GetEnergy();
12448 }
12449 return energy;
12450 }
12451
12452
12453 override void OnEnergyConsumed()
12454 {
12455 super.OnEnergyConsumed();
12456
12458 }
12459
12460 override void OnEnergyAdded()
12461 {
12462 super.OnEnergyAdded();
12463
12465 }
12466
12467 // Converts energy (from Energy Manager) to quantity, if enabled.
12469 {
12470 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12471 {
12472 if (HasQuantity())
12473 {
12474 float energy_0to1 = GetCompEM().GetEnergy0To1();
12475 SetQuantityNormalized(energy_0to1);
12476 }
12477 }
12478 }
12479
12480 //----------------------------------------------------------------
12481 float GetHeatIsolationInit()
12482 {
12483 return ConfigGetFloat("heatIsolation");
12484 }
12485
12486 float GetHeatIsolation()
12487 {
12488 return m_HeatIsolation;
12489 }
12490
12491 float GetDryingIncrement(string pIncrementName)
12492 {
12493 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12494 if (GetGame().ConfigIsExisting(paramPath))
12495 return GetGame().ConfigGetFloat(paramPath);
12496
12497 return 0.0;
12498 }
12499
12500 float GetSoakingIncrement(string pIncrementName)
12501 {
12502 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12503 if (GetGame().ConfigIsExisting(paramPath))
12504 return GetGame().ConfigGetFloat(paramPath);
12505
12506 return 0.0;
12507 }
12508 //----------------------------------------------------------------
12509 override void SetWet(float value, bool allow_client = false)
12510 {
12511 if (!IsServerCheck(allow_client))
12512 return;
12513
12514 float min = GetWetMin();
12515 float max = GetWetMax();
12516
12517 float previousValue = m_VarWet;
12518
12519 m_VarWet = Math.Clamp(value, min, max);
12520
12521 if (previousValue != m_VarWet)
12522 {
12523 SetVariableMask(VARIABLE_WET);
12524 OnWetChanged(m_VarWet, previousValue);
12525 }
12526 }
12527 //----------------------------------------------------------------
12528 override void AddWet(float value)
12529 {
12530 SetWet(GetWet() + value);
12531 }
12532 //----------------------------------------------------------------
12533 override void SetWetMax()
12534 {
12536 }
12537 //----------------------------------------------------------------
12538 override float GetWet()
12539 {
12540 return m_VarWet;
12541 }
12542 //----------------------------------------------------------------
12543 override float GetWetMax()
12544 {
12545 return m_VarWetMax;
12546 }
12547 //----------------------------------------------------------------
12548 override float GetWetMin()
12549 {
12550 return m_VarWetMin;
12551 }
12552 //----------------------------------------------------------------
12553 override float GetWetInit()
12554 {
12555 return m_VarWetInit;
12556 }
12557 //----------------------------------------------------------------
12558 override void OnWetChanged(float newVal, float oldVal)
12559 {
12560 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12561 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12562 if (newLevel != oldLevel)
12563 {
12564 OnWetLevelChanged(newLevel,oldLevel);
12565 }
12566 }
12567
12568 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12569 {
12570 SetWeightDirty();
12571 }
12572
12573 override EWetnessLevel GetWetLevel()
12574 {
12575 return GetWetLevelInternal(m_VarWet);
12576 }
12577
12578 //----------------------------------------------------------------
12579
12580 override void SetStoreLoad(bool value)
12581 {
12582 m_IsStoreLoad = value;
12583 }
12584
12585 override bool IsStoreLoad()
12586 {
12587 return m_IsStoreLoad;
12588 }
12589
12590 override void SetStoreLoadedQuantity(float value)
12591 {
12592 m_StoreLoadedQuantity = value;
12593 }
12594
12595 override float GetStoreLoadedQuantity()
12596 {
12597 return m_StoreLoadedQuantity;
12598 }
12599
12600 //----------------------------------------------------------------
12601
12602 float GetItemModelLength()
12603 {
12604 if (ConfigIsExisting("itemModelLength"))
12605 {
12606 return ConfigGetFloat("itemModelLength");
12607 }
12608 return 0;
12609 }
12610
12611 float GetItemAttachOffset()
12612 {
12613 if (ConfigIsExisting("itemAttachOffset"))
12614 {
12615 return ConfigGetFloat("itemAttachOffset");
12616 }
12617 return 0;
12618 }
12619
12620 override void SetCleanness(int value, bool allow_client = false)
12621 {
12622 if (!IsServerCheck(allow_client))
12623 return;
12624
12625 int previousValue = m_Cleanness;
12626
12627 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12628
12629 if (previousValue != m_Cleanness)
12630 SetVariableMask(VARIABLE_CLEANNESS);
12631 }
12632
12633 override int GetCleanness()
12634 {
12635 return m_Cleanness;
12636 }
12637
12639 {
12640 return true;
12641 }
12642
12643 //----------------------------------------------------------------
12644 // ATTACHMENT LOCKING
12645 // Getters relevant to generic ActionLockAttachment
12646 int GetLockType()
12647 {
12648 return m_LockType;
12649 }
12650
12651 string GetLockSoundSet()
12652 {
12653 return m_LockSoundSet;
12654 }
12655
12656 //----------------------------------------------------------------
12657 //------------------------- Color
12658 // sets items color variable given color components
12659 override void SetColor(int r, int g, int b, int a)
12660 {
12665 SetVariableMask(VARIABLE_COLOR);
12666 }
12668 override void GetColor(out int r,out int g,out int b,out int a)
12669 {
12674 }
12675
12676 bool IsColorSet()
12677 {
12678 return IsVariableSet(VARIABLE_COLOR);
12679 }
12680
12682 string GetColorString()
12683 {
12684 int r,g,b,a;
12685 GetColor(r,g,b,a);
12686 r = r/255;
12687 g = g/255;
12688 b = b/255;
12689 a = a/255;
12690 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12691 }
12692 //----------------------------------------------------------------
12693 //------------------------- LiquidType
12694
12695 override void SetLiquidType(int value, bool allow_client = false)
12696 {
12697 if (!IsServerCheck(allow_client))
12698 return;
12699
12700 int old = m_VarLiquidType;
12701 m_VarLiquidType = value;
12702 OnLiquidTypeChanged(old,value);
12703 SetVariableMask(VARIABLE_LIQUIDTYPE);
12704 }
12705
12706 int GetLiquidTypeInit()
12707 {
12708 return ConfigGetInt("varLiquidTypeInit");
12709 }
12710
12711 override int GetLiquidType()
12712 {
12713 return m_VarLiquidType;
12714 }
12715
12716 protected void OnLiquidTypeChanged(int oldType, int newType)
12717 {
12718 if (newType == LIQUID_NONE && GetIsFrozen())
12719 SetFrozen(false);
12720 }
12721
12723 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12724 {
12725 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12726 }
12727
12728 // -------------------------------------------------------------------------
12730 void OnInventoryEnter(Man player)
12731 {
12732 PlayerBase nplayer;
12733 if (PlayerBase.CastTo(nplayer, player))
12734 {
12735 m_CanPlayImpactSound = true;
12736 //nplayer.OnItemInventoryEnter(this);
12737 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12738 }
12739 }
12740
12741 // -------------------------------------------------------------------------
12743 void OnInventoryExit(Man player)
12744 {
12745 PlayerBase nplayer;
12746 if (PlayerBase.CastTo(nplayer,player))
12747 {
12748 //nplayer.OnItemInventoryExit(this);
12749 nplayer.SetEnableQuickBarEntityShortcut(this,false);
12750
12751 }
12752
12753 //if (!GetGame().IsDedicatedServer())
12754 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12755
12756
12757 if (HasEnergyManager())
12758 {
12759 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12760 }
12761 }
12762
12763 // ADVANCED PLACEMENT EVENTS
12764 override void OnPlacementStarted(Man player)
12765 {
12766 super.OnPlacementStarted(player);
12767
12768 SetTakeable(false);
12769 }
12770
12771 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12772 {
12773 if (m_AdminLog)
12774 {
12775 m_AdminLog.OnPlacementComplete(player, this);
12776 }
12777
12778 super.OnPlacementComplete(player, position, orientation);
12779 }
12780
12781 //-----------------------------
12782 // AGENT SYSTEM
12783 //-----------------------------
12784 //--------------------------------------------------------------------------
12785 bool ContainsAgent(int agent_id)
12786 {
12787 if (agent_id & m_AttachedAgents)
12788 {
12789 return true;
12790 }
12791 else
12792 {
12793 return false;
12794 }
12795 }
12796
12797 //--------------------------------------------------------------------------
12798 override void RemoveAgent(int agent_id)
12799 {
12800 if (ContainsAgent(agent_id))
12801 {
12802 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12803 }
12804 }
12805
12806 //--------------------------------------------------------------------------
12807 override void RemoveAllAgents()
12808 {
12809 m_AttachedAgents = 0;
12810 }
12811 //--------------------------------------------------------------------------
12812 override void RemoveAllAgentsExcept(int agent_to_keep)
12813 {
12814 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12815 }
12816 // -------------------------------------------------------------------------
12817 override void InsertAgent(int agent, float count = 1)
12818 {
12819 if (count < 1)
12820 return;
12821 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12823 }
12824
12826 void TransferAgents(int agents)
12827 {
12829 }
12830
12831 // -------------------------------------------------------------------------
12832 override int GetAgents()
12833 {
12834 return m_AttachedAgents;
12835 }
12836 //----------------------------------------------------------------------
12837
12838 /*int GetContaminationType()
12839 {
12840 int contamination_type;
12841
12842 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12843 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12844 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12845 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12846
12847 Edible_Base edible = Edible_Base.Cast(this);
12848 int agents = GetAgents();
12849 if (edible)
12850 {
12851 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12852 if (profile)
12853 {
12854 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12855 }
12856 }
12857 if (agents & CONTAMINATED_MASK)
12858 {
12859 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12860 }
12861 if (agents & POISONED_MASK)
12862 {
12863 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12864 }
12865 if (agents & NERVE_GAS_MASK)
12866 {
12867 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12868 }
12869 if (agents & DIRTY_MASK)
12870 {
12871 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12872 }
12873
12874 return agents;
12875 }*/
12876
12877 // -------------------------------------------------------------------------
12878 bool LoadAgents(ParamsReadContext ctx, int version)
12879 {
12880 if (!ctx.Read(m_AttachedAgents))
12881 return false;
12882 return true;
12883 }
12884 // -------------------------------------------------------------------------
12886 {
12887
12889 }
12890 // -------------------------------------------------------------------------
12891
12893 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12894 {
12895 super.CheckForRoofLimited(timeTresholdMS);
12896
12897 float time = GetGame().GetTime();
12898 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12899 {
12900 m_PreviousRoofTestTime = time;
12901 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12902 }
12903 }
12904
12905 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12906 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12907 {
12908 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12909 {
12910 return 0;
12911 }
12912
12913 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12914 {
12915 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12916 if (filter)
12917 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12918 else
12919 return 0;//otherwise return 0 when no filter attached
12920 }
12921
12922 string subclassPath, entryName;
12923
12924 switch (type)
12925 {
12926 case DEF_BIOLOGICAL:
12927 entryName = "biological";
12928 break;
12929 case DEF_CHEMICAL:
12930 entryName = "chemical";
12931 break;
12932 default:
12933 entryName = "biological";
12934 break;
12935 }
12936
12937 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12938
12939 return GetGame().ConfigGetFloat(subclassPath + entryName);
12940 }
12941
12942
12943
12945 override void EEOnCECreate()
12946 {
12947 if (!IsMagazine())
12949
12951 }
12952
12953
12954 //-------------------------
12955 // OPEN/CLOSE USER ACTIONS
12956 //-------------------------
12958 void Open();
12959 void Close();
12960 bool IsOpen()
12961 {
12962 return true;
12963 }
12964
12965 override bool CanDisplayCargo()
12966 {
12967 return IsOpen();
12968 }
12969
12970
12971 // ------------------------------------------------------------
12972 // CONDITIONS
12973 // ------------------------------------------------------------
12974 override bool CanPutInCargo(EntityAI parent)
12975 {
12976 if (parent)
12977 {
12978 if (parent.IsInherited(DayZInfected))
12979 return true;
12980
12981 if (!parent.IsRuined())
12982 return true;
12983 }
12984
12985 return true;
12986 }
12987
12988 override bool CanPutAsAttachment(EntityAI parent)
12989 {
12990 if (!super.CanPutAsAttachment(parent))
12991 {
12992 return false;
12993 }
12994
12995 if (!IsRuined() && !parent.IsRuined())
12996 {
12997 return true;
12998 }
12999
13000 return false;
13001 }
13002
13003 override bool CanReceiveItemIntoCargo(EntityAI item)
13004 {
13005 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13006 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13007 // return false;
13008
13009 return super.CanReceiveItemIntoCargo(item);
13010 }
13011
13012 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
13013 {
13014 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13015 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13016 // return false;
13017
13018 GameInventory attachmentInv = attachment.GetInventory();
13019 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13020 {
13021 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13022 return false;
13023 }
13024
13025 InventoryLocation loc = new InventoryLocation();
13026 attachment.GetInventory().GetCurrentInventoryLocation(loc);
13027 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
13028 return false;
13029
13030 return super.CanReceiveAttachment(attachment, slotId);
13031 }
13032
13033 override bool CanReleaseAttachment(EntityAI attachment)
13034 {
13035 if (!super.CanReleaseAttachment(attachment))
13036 return false;
13037
13038 return GetInventory().AreChildrenAccessible();
13039 }
13040
13041 /*override bool CanLoadAttachment(EntityAI attachment)
13042 {
13043 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13044 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13045 // return false;
13046
13047 GameInventory attachmentInv = attachment.GetInventory();
13048 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13049 {
13050 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
13051 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
13052
13053 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13054 return false;
13055 }
13056
13057 return super.CanLoadAttachment(attachment);
13058 }*/
13059
13060 // Plays muzzle flash particle effects
13061 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13062 {
13063 int id = muzzle_owner.GetMuzzleID();
13064 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
13065
13066 if (WPOF_array)
13067 {
13068 for (int i = 0; i < WPOF_array.Count(); i++)
13069 {
13070 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
13071
13072 if (WPOF)
13073 {
13074 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
13075 }
13076 }
13077 }
13078 }
13079
13080 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
13081 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13082 {
13083 int id = muzzle_owner.GetMuzzleID();
13084 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
13085
13086 if (WPOBE_array)
13087 {
13088 for (int i = 0; i < WPOBE_array.Count(); i++)
13089 {
13090 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
13091
13092 if (WPOBE)
13093 {
13094 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13095 }
13096 }
13097 }
13098 }
13099
13100 // Plays all weapon overheating particles
13101 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13102 {
13103 int id = muzzle_owner.GetMuzzleID();
13104 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13105
13106 if (WPOOH_array)
13107 {
13108 for (int i = 0; i < WPOOH_array.Count(); i++)
13109 {
13110 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13111
13112 if (WPOOH)
13113 {
13114 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13115 }
13116 }
13117 }
13118 }
13119
13120 // Updates all weapon overheating particles
13121 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13122 {
13123 int id = muzzle_owner.GetMuzzleID();
13124 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13125
13126 if (WPOOH_array)
13127 {
13128 for (int i = 0; i < WPOOH_array.Count(); i++)
13129 {
13130 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13131
13132 if (WPOOH)
13133 {
13134 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13135 }
13136 }
13137 }
13138 }
13139
13140 // Stops overheating particles
13141 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13142 {
13143 int id = muzzle_owner.GetMuzzleID();
13144 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13145
13146 if (WPOOH_array)
13147 {
13148 for (int i = 0; i < WPOOH_array.Count(); i++)
13149 {
13150 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13151
13152 if (WPOOH)
13153 {
13154 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13155 }
13156 }
13157 }
13158 }
13159
13160 //----------------------------------------------------------------
13161 //Item Behaviour - unified approach
13162 override bool IsHeavyBehaviour()
13163 {
13164 if (m_ItemBehaviour == 0)
13165 {
13166 return true;
13167 }
13168
13169 return false;
13170 }
13171
13172 override bool IsOneHandedBehaviour()
13173 {
13174 if (m_ItemBehaviour == 1)
13175 {
13176 return true;
13177 }
13178
13179 return false;
13180 }
13181
13182 override bool IsTwoHandedBehaviour()
13183 {
13184 if (m_ItemBehaviour == 2)
13185 {
13186 return true;
13187 }
13188
13189 return false;
13190 }
13191
13192 bool IsDeployable()
13193 {
13194 return false;
13195 }
13196
13198 float GetDeployTime()
13199 {
13200 return UATimeSpent.DEFAULT_DEPLOY;
13201 }
13202
13203
13204 //----------------------------------------------------------------
13205 // Item Targeting (User Actions)
13206 override void SetTakeable(bool pState)
13207 {
13208 m_IsTakeable = pState;
13209 SetSynchDirty();
13210 }
13211
13212 override bool IsTakeable()
13213 {
13214 return m_IsTakeable;
13215 }
13216
13217 // For cases where we want to show object widget which cant be taken to hands
13219 {
13220 return false;
13221 }
13222
13224 protected void PreLoadSoundAttachmentType()
13225 {
13226 string att_type = "None";
13227
13228 if (ConfigIsExisting("soundAttType"))
13229 {
13230 att_type = ConfigGetString("soundAttType");
13231 }
13232
13233 m_SoundAttType = att_type;
13234 }
13235
13236 override string GetAttachmentSoundType()
13237 {
13238 return m_SoundAttType;
13239 }
13240
13241 //----------------------------------------------------------------
13242 //SOUNDS - ItemSoundHandler
13243 //----------------------------------------------------------------
13244
13245 string GetPlaceSoundset(); // played when deploy starts
13246 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13247 string GetDeploySoundset(); // played when deploy sucessfully finishes
13248 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13249 string GetFoldSoundset(); // played when fold sucessfully finishes
13250
13252 {
13253 if (!m_ItemSoundHandler)
13255
13256 return m_ItemSoundHandler;
13257 }
13258
13259 // override to initialize sounds
13260 protected void InitItemSounds()
13261 {
13262 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
13263 return;
13264
13266
13267 if (GetPlaceSoundset() != string.Empty)
13268 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13269
13270 if (GetDeploySoundset() != string.Empty)
13271 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13272
13273 SoundParameters params = new SoundParameters();
13274 params.m_Loop = true;
13275 if (GetLoopDeploySoundset() != string.Empty)
13276 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13277 }
13278
13279 // Start sound using ItemSoundHandler
13280 void StartItemSoundServer(int id)
13281 {
13282 if (!GetGame().IsServer())
13283 return;
13284
13285 m_SoundSyncPlay = id;
13286 SetSynchDirty();
13287
13288 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13290 }
13291
13292 // Stop sound using ItemSoundHandler
13293 void StopItemSoundServer(int id)
13294 {
13295 if (!GetGame().IsServer())
13296 return;
13297
13298 m_SoundSyncStop = id;
13299 SetSynchDirty();
13300
13301 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13303 }
13304
13305 protected void ClearStartItemSoundServer()
13306 {
13307 m_SoundSyncPlay = 0;
13308 }
13309
13310 protected void ClearStopItemSoundServer()
13311 {
13312 m_SoundSyncStop = 0;
13313 }
13314
13316 void PlayAttachSound(string slot_type)
13317 {
13318 if (!GetGame().IsDedicatedServer())
13319 {
13320 if (ConfigIsExisting("attachSoundSet"))
13321 {
13322 string cfg_path = "";
13323 string soundset = "";
13324 string type_name = GetType();
13325
13326 TStringArray cfg_soundset_array = new TStringArray;
13327 TStringArray cfg_slot_array = new TStringArray;
13328 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13329 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13330
13331 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13332 {
13333 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13334 {
13335 if (cfg_slot_array[i] == slot_type)
13336 {
13337 soundset = cfg_soundset_array[i];
13338 break;
13339 }
13340 }
13341 }
13342
13343 if (soundset != "")
13344 {
13345 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13346 sound.SetAutodestroy(true);
13347 }
13348 }
13349 }
13350 }
13351
13352 void PlayDetachSound(string slot_type)
13353 {
13354 //TODO - evaluate if needed and devise universal config structure if so
13355 }
13356
13357 void OnApply(PlayerBase player);
13358
13360 {
13361 return 1.0;
13362 };
13363 //returns applicable selection
13364 array<string> GetHeadHidingSelection()
13365 {
13367 }
13368
13370 {
13372 }
13373
13374 WrittenNoteData GetWrittenNoteData() {};
13375
13377 {
13378 SetDynamicPhysicsLifeTime(0.01);
13379 m_ItemBeingDroppedPhys = false;
13380 }
13381
13383 {
13384 array<string> zone_names = new array<string>;
13385 GetDamageZones(zone_names);
13386 for (int i = 0; i < zone_names.Count(); i++)
13387 {
13388 SetHealthMax(zone_names.Get(i),"Health");
13389 }
13390 SetHealthMax("","Health");
13391 }
13392
13394 void SetZoneDamageCEInit()
13395 {
13396 float global_health = GetHealth01("","Health");
13397 array<string> zones = new array<string>;
13398 GetDamageZones(zones);
13399 //set damage of all zones to match global health level
13400 for (int i = 0; i < zones.Count(); i++)
13401 {
13402 SetHealth01(zones.Get(i),"Health",global_health);
13403 }
13404 }
13405
13407 bool IsCoverFaceForShave(string slot_name)
13408 {
13409 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13410 }
13411
13412 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13413 {
13414 if (!hasRootAsPlayer)
13415 {
13416 if (refParentIB)
13417 {
13418 // parent is wet
13419 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13420 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13421 // parent has liquid inside
13422 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13423 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13424 // drying
13425 else if (m_VarWet > m_VarWetMin)
13426 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13427 }
13428 else
13429 {
13430 // drying on ground or inside non-itembase (car, ...)
13431 if (m_VarWet > m_VarWetMin)
13432 AddWet(-1 * delta * GetDryingIncrement("ground"));
13433 }
13434 }
13435 }
13436
13437 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13438 {
13440 {
13441 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13442 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13443 {
13444 float heatPermCoef = 1.0;
13445 EntityAI ent = this;
13446 while (ent)
13447 {
13448 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13449 ent = ent.GetHierarchyParent();
13450 }
13451
13452 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13453 }
13454 }
13455 }
13456
13457 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13458 {
13459 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13460 EntityAI parent = GetHierarchyParent();
13461 if (!parent)
13462 {
13463 hasParent = false;
13464 hasRootAsPlayer = false;
13465 }
13466 else
13467 {
13468 hasParent = true;
13469 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13470 refParentIB = ItemBase.Cast(parent);
13471 }
13472 }
13473
13474 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13475 {
13476 // this is stub, implemented on Edible_Base
13477 }
13478
13479 bool CanDecay()
13480 {
13481 // return true used on selected food clases so they can decay
13482 return false;
13483 }
13484
13485 protected bool CanProcessDecay()
13486 {
13487 // this is stub, implemented on Edible_Base class
13488 // used to determine whether it is still necessary for the food to decay
13489 return false;
13490 }
13491
13492 protected bool CanHaveWetness()
13493 {
13494 // return true used on selected items that have a wetness effect
13495 return false;
13496 }
13497
13499 bool CanBeConsumed(ConsumeConditionData data = null)
13500 {
13501 return !GetIsFrozen() && IsOpen();
13502 }
13503
13504 override void ProcessVariables()
13505 {
13506 bool hasParent = false, hasRootAsPlayer = false;
13507 ItemBase refParentIB;
13508
13509 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13510 bool foodDecay = g_Game.IsFoodDecayEnabled();
13511
13512 if (wwtu || foodDecay)
13513 {
13514 bool processWetness = wwtu && CanHaveWetness();
13515 bool processTemperature = wwtu && CanHaveTemperature();
13516 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13517
13518 if (processWetness || processTemperature || processDecay)
13519 {
13520 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13521
13522 if (processWetness)
13523 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13524
13525 if (processTemperature)
13526 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13527
13528 if (processDecay)
13529 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13530 }
13531 }
13532 }
13533
13536 {
13537 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13538 }
13539
13540 override float GetTemperatureFreezeThreshold()
13541 {
13543 return Liquid.GetFreezeThreshold(GetLiquidType());
13544
13545 return super.GetTemperatureFreezeThreshold();
13546 }
13547
13548 override float GetTemperatureThawThreshold()
13549 {
13551 return Liquid.GetThawThreshold(GetLiquidType());
13552
13553 return super.GetTemperatureThawThreshold();
13554 }
13555
13556 override float GetItemOverheatThreshold()
13557 {
13559 return Liquid.GetBoilThreshold(GetLiquidType());
13560
13561 return super.GetItemOverheatThreshold();
13562 }
13563
13564 override float GetTemperatureFreezeTime()
13565 {
13566 if (HasQuantity())
13567 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13568
13569 return super.GetTemperatureFreezeTime();
13570 }
13571
13572 override float GetTemperatureThawTime()
13573 {
13574 if (HasQuantity())
13575 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13576
13577 return super.GetTemperatureThawTime();
13578 }
13579
13581 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13583 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13584
13585 bool IsCargoException4x3(EntityAI item)
13586 {
13587 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13588 }
13589
13591 {
13592 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13593 }
13594
13596 void AddLightSourceItem(ItemBase lightsource)
13597 {
13598 m_LightSourceItem = lightsource;
13599 }
13600
13602 {
13603 m_LightSourceItem = null;
13604 }
13605
13607 {
13608 return m_LightSourceItem;
13609 }
13610
13612 array<int> GetValidFinishers()
13613 {
13614 return null;
13615 }
13616
13618 bool GetActionWidgetOverride(out typename name)
13619 {
13620 return false;
13621 }
13622
13623 bool PairWithDevice(notnull ItemBase otherDevice)
13624 {
13625 if (GetGame().IsServer())
13626 {
13627 ItemBase explosive = otherDevice;
13629 if (!trg)
13630 {
13631 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13632 explosive = this;
13633 }
13634
13635 explosive.PairRemote(trg);
13636 trg.SetControlledDevice(explosive);
13637
13638 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13639 trg.SetPersistentPairID(persistentID);
13640 explosive.SetPersistentPairID(persistentID);
13641
13642 return true;
13643 }
13644 return false;
13645 }
13646
13648 float GetBaitEffectivity()
13649 {
13650 float ret = 1.0;
13651 if (HasQuantity())
13652 ret *= GetQuantityNormalized();
13653 ret *= GetHealth01();
13654
13655 return ret;
13656 }
13657
13658 #ifdef DEVELOPER
13659 override void SetDebugItem()
13660 {
13661 super.SetDebugItem();
13662 _itemBase = this;
13663 }
13664
13665 override string GetDebugText()
13666 {
13667 string text = super.GetDebugText();
13668
13669 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13670 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13671
13672 return text;
13673 }
13674 #endif
13675
13676 bool CanBeUsedForSuicide()
13677 {
13678 return true;
13679 }
13680
13682 //DEPRECATED BELOW
13684 // Backwards compatibility
13685 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13686 {
13687 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13688 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13689 }
13690
13691 // replaced by ItemSoundHandler
13692 protected EffectSound m_SoundDeployFinish;
13693 protected EffectSound m_SoundPlace;
13694 protected EffectSound m_DeployLoopSoundEx;
13695 protected EffectSound m_SoundDeploy;
13696 bool m_IsPlaceSound;
13697 bool m_IsDeploySound;
13699
13700 string GetDeployFinishSoundset();
13701 void PlayDeploySound();
13702 void PlayDeployFinishSound();
13703 void PlayPlaceSound();
13704 void PlayDeployLoopSoundEx();
13705 void StopDeployLoopSoundEx();
13706 void SoundSynchRemoteReset();
13707 void SoundSynchRemote();
13708 bool UsesGlobalDeploy(){return false;}
13709 bool CanPlayDeployLoopSound(){return false;}
13711 bool IsPlaceSound(){return m_IsPlaceSound;}
13712 bool IsDeploySound(){return m_IsDeploySound;}
13713 void SetIsPlaceSound(bool is_place_sound);
13714 void SetIsDeploySound(bool is_deploy_sound);
13715}
13716
13717EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13718{
13719 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13720 if (entity)
13721 {
13722 bool is_item = entity.IsInherited(ItemBase);
13723 if (is_item && full_quantity)
13724 {
13725 ItemBase item = ItemBase.Cast(entity);
13726 item.SetQuantity(item.GetQuantityInit());
13727 }
13728 }
13729 else
13730 {
13731 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13732 return NULL;
13733 }
13734 return entity;
13735}
13736
13737void SetupSpawnedItem(ItemBase item, float health, float quantity)
13738{
13739 if (item)
13740 {
13741 if (health > 0)
13742 item.SetHealth("", "", health);
13743
13744 if (item.CanHaveTemperature())
13745 {
13746 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13747 if (item.CanFreeze())
13748 item.SetFrozen(false);
13749 }
13750
13751 if (item.HasEnergyManager())
13752 {
13753 if (quantity >= 0)
13754 {
13755 item.GetCompEM().SetEnergy0To1(quantity);
13756 }
13757 else
13758 {
13759 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13760 }
13761 }
13762 else if (item.IsMagazine())
13763 {
13764 Magazine mag = Magazine.Cast(item);
13765 if (quantity >= 0)
13766 {
13767 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13768 }
13769 else
13770 {
13771 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13772 }
13773
13774 }
13775 else
13776 {
13777 if (quantity >= 0)
13778 {
13779 item.SetQuantityNormalized(quantity, false);
13780 }
13781 else
13782 {
13783 item.SetQuantity(Math.AbsFloat(quantity));
13784 }
13785
13786 }
13787 }
13788}
13789
13790#ifdef DEVELOPER
13791ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13792#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения 3_Game/Entities/EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/Entities/EntityAI.c:2
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:14
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
int GetLiquidType()
Определения CCTWaterSurface.c:129
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:497
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:559
class GP5GasMask extends MaskBase ItemBase
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6380
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5620
bool HidesSelectionBySlot()
Определения ItemBase.c:9347
float m_VarWetMin
Определения ItemBase.c:4881
void SplitItem(PlayerBase player)
Определения ItemBase.c:6831
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9568
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8795
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8229
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5625
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8938
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6798
override bool IsHeavyBehaviour()
Определения ItemBase.c:9140
override void SetWetMax()
Определения ItemBase.c:8511
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9385
void ClearStartItemSoundServer()
Определения ItemBase.c:9283
float m_VarWet
Определения ItemBase.c:4878
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9415
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8790
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4941
bool CanBeMovedOverride()
Определения ItemBase.c:7522
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8487
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4927
override void ProcessVariables()
Определения ItemBase.c:9482
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4955
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8321
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8856
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8701
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5211
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4953
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9518
bool m_IsSoundSynchRemote
Определения ItemBase.c:9676
float m_OverheatingShots
Определения ItemBase.c:4948
void StopItemSoundServer(int id)
Определения ItemBase.c:9271
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5640
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5364
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9542
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4965
bool CanBeCooked()
Определения ItemBase.c:7478
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5707
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4977
bool m_RecipesInitialized
Определения ItemBase.c:4863
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6471
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9526
override void OnEnergyConsumed()
Определения ItemBase.c:8431
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8360
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8551
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8316
ref TIntArray m_InteractActions
Определения ItemBase.c:4929
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7542
float m_VarQuantity
Определения ItemBase.c:4869
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9687
override float GetWetMax()
Определения ItemBase.c:8521
bool CanBeUsedForSuicide()
Определения ItemBase.c:9654
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7117
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5845
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7696
void StartItemSoundServer(int id)
Определения ItemBase.c:9258
void DoAmmoExplosion()
Определения ItemBase.c:6315
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4940
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6655
int GetItemSize()
Определения ItemBase.c:7507
bool m_CanBeMovedOverride
Определения ItemBase.c:4906
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6239
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5432
bool CanDecay()
Определения ItemBase.c:9457
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8202
void SetQuantityMax()
Определения ItemBase.c:8207
override float GetQuantity()
Определения ItemBase.c:8296
int m_ColorComponentR
Определения ItemBase.c:4918
int m_ShotsToStartOverheating
Определения ItemBase.c:4950
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8536
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5439
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9039
void OnOverheatingDecay()
Определения ItemBase.c:5402
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8469
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4884
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5540
bool UsesGlobalDeploy()
Определения ItemBase.c:9686
int m_ItemBehaviour
Определения ItemBase.c:4899
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9011
float m_HeatIsolation
Определения ItemBase.c:4894
float m_VarWetInit
Определения ItemBase.c:4880
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5885
void SetCEBasedQuantity()
Определения ItemBase.c:5653
bool m_CanPlayImpactSound
Определения ItemBase.c:4890
override string GetAttachmentSoundType()
Определения ItemBase.c:9214
float GetOverheatingCoef()
Определения ItemBase.c:5459
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9342
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9294
override bool IsStoreLoad()
Определения ItemBase.c:8563
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7093
bool IsLightSource()
Определения ItemBase.c:5781
bool m_HasQuantityBar
Определения ItemBase.c:4912
void SetResultOfSplit(bool value)
Определения ItemBase.c:7088
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6719
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6889
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5467
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8478
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9119
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8573
int m_LockType
Определения ItemBase.c:4966
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4971
bool m_CanBeDigged
Определения ItemBase.c:4913
float m_ItemAttachOffset
Определения ItemBase.c:4896
float GetItemModelLength()
Определения ItemBase.c:8580
bool m_ThrowItemOnDrop
Определения ItemBase.c:4904
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7841
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8871
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8464
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7122
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9513
bool CanHaveWetness()
Определения ItemBase.c:9470
int m_CleannessMin
Определения ItemBase.c:4886
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8804
string IDToName(int id)
Определения ItemBase.c:7689
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9477
float GetHeatIsolationInit()
Определения ItemBase.c:8459
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7529
override bool HasQuantity()
Определения ItemBase.c:8291
float m_VarWetPrev
Определения ItemBase.c:4879
int m_SoundSyncStop
Определения ItemBase.c:4973
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9563
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4928
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5549
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5234
int m_VarLiquidType
Определения ItemBase.c:4898
int m_QuickBarBonus
Определения ItemBase.c:4900
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9202
override float GetWetInit()
Определения ItemBase.c:8531
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4892
int m_SoundSyncPlay
Определения ItemBase.c:4972
int m_MaxOverheatingValue
Определения ItemBase.c:4951
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4875
bool m_IsTakeable
Определения ItemBase.c:4903
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6428
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4943
string GetLockSoundSet()
Определения ItemBase.c:8629
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8660
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9590
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6895
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4855
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9229
override int GetQuantityMin()
Определения ItemBase.c:8280
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6634
override int GetQuickBarBonus()
Определения ItemBase.c:5119
override void SetTakeable(bool pState)
Определения ItemBase.c:9184
float m_OverheatingDecayInterval
Определения ItemBase.c:4952
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6448
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9435
bool CanProcessDecay()
Определения ItemBase.c:9463
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5630
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9579
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7493
bool can_this_be_combined
Определения ItemBase.c:4908
EffectSound m_SoundDeploy
Определения ItemBase.c:9673
int m_Count
Определения ItemBase.c:4874
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9626
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9176
override bool IsSplitable()
Определения ItemBase.c:6415
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6399
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7805
void ConvertEnergyToQuantity()
Определения ItemBase.c:8446
override void RemoveAllAgents()
Определения ItemBase.c:8785
override void SetQuantityToMinimum()
Определения ItemBase.c:8213
bool m_WantPlayImpactSound
Определения ItemBase.c:4889
override float GetTemperatureThawTime()
Определения ItemBase.c:9550
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4942
int m_ColorComponentG
Определения ItemBase.c:4919
float m_StoreLoadedQuantity
Определения ItemBase.c:4876
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7560
int m_ColorComponentA
Определения ItemBase.c:4921
int m_VarQuantityInit
Определения ItemBase.c:4871
float GetFilterDamageRatio()
Определения ItemBase.c:5534
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8673
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6865
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8220
bool m_HideSelectionsBySlot
Определения ItemBase.c:4956
bool IsOverheatingEffectActive()
Определения ItemBase.c:5397
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5814
int GetLiquidContainerMask()
Определения ItemBase.c:5751
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7002
ref Timer m_CheckOverheating
Определения ItemBase.c:4949
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5445
float GetEnergy()
Определения ItemBase.c:8420
bool CanBeDigged()
Определения ItemBase.c:5830
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9596
bool IsNVG()
Определения ItemBase.c:5762
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8380
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9372
bool m_IsDeploySound
Определения ItemBase.c:9675
bool CanEat()
Определения ItemBase.c:7453
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9079
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9150
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9574
bool IsLiquidContainer()
Определения ItemBase.c:5746
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7473
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8307
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8863
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8261
int m_CleannessInit
Определения ItemBase.c:4885
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5529
override int GetAgents()
Определения ItemBase.c:8810
int m_VarQuantityMax
Определения ItemBase.c:4873
override bool IsHologram()
Определения ItemBase.c:5825
float GetItemAttachOffset()
Определения ItemBase.c:8589
bool IsPlaceSound()
Определения ItemBase.c:9689
static int GetDebugActionsMask()
Определения ItemBase.c:5615
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9452
override bool IsItemBase()
Определения ItemBase.c:7606
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9160
void ExplodeAmmo()
Определения ItemBase.c:6302
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7078
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8884
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9059
override void OnEnergyAdded()
Определения ItemBase.c:8438
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5774
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9672
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7746
void StopItemDynamicPhysics()
Определения ItemBase.c:9354
bool HasFoodStage()
Определения ItemBase.c:7466
override void SetStoreLoad(bool value)
Определения ItemBase.c:8558
float GetOverheatingValue()
Определения ItemBase.c:5359
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8763
override void AddWet(float value)
Определения ItemBase.c:8506
bool IsLiquidPresent()
Определения ItemBase.c:5741
bool IsFullQuantity()
Определения ItemBase.c:8301
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6015
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6770
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6746
int m_CleannessMax
Определения ItemBase.c:4887
float m_VarStackMax
Определения ItemBase.c:4875
ref Timer m_PhysDropTimer
Определения ItemBase.c:4962
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7578
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8568
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4916
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5380
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5695
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7500
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8694
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5426
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8616
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4947
int m_LiquidContainerMask
Определения ItemBase.c:4897
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9390
override int GetCleanness()
Определения ItemBase.c:8611
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9601
bool IsDeploySound()
Определения ItemBase.c:9690
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5635
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9099
int m_VarQuantityMin
Определения ItemBase.c:4872
void PerformDamageSystemReinit()
Определения ItemBase.c:9360
override void ClearInventory()
Определения ItemBase.c:8399
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4944
ItemBase GetLightSourceItem()
Определения ItemBase.c:9584
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7596
override float GetItemOverheatThreshold()
Определения ItemBase.c:9534
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4909
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7710
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6685
float m_ItemModelLength
Определения ItemBase.c:4895
bool m_IsHologram
Определения ItemBase.c:4902
static int m_DebugActionsMask
Определения ItemBase.c:4862
void KillAllOverheatingParticles()
Определения ItemBase.c:5495
bool CanBeCookedOnStick()
Определения ItemBase.c:7483
override int GetQuantityMax()
Определения ItemBase.c:8248
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7156
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8654
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8776
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4905
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8966
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9330
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4856
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9663
override bool IsBeingPlaced()
Определения ItemBase.c:5809
int GetQuantityInit()
Определения ItemBase.c:8285
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7098
bool IsResultOfSplit()
Определения ItemBase.c:7083
bool m_FixDamageSystemInit
Определения ItemBase.c:4907
float m_ImpactSpeed
Определения ItemBase.c:4891
bool m_IsStoreLoad
Определения ItemBase.c:4910
int GetLiquidTypeInit()
Определения ItemBase.c:8684
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4925
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5682
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6557
int m_AttachedAgents
Определения ItemBase.c:4933
string m_LockSoundSet
Определения ItemBase.c:4968
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5303
float m_VarQuantityPrev
Определения ItemBase.c:4870
bool IsSoundSynchRemote()
Определения ItemBase.c:9688
bool m_CanShowQuantity
Определения ItemBase.c:4911
override void OnRightClick()
Определения ItemBase.c:6938
int m_ColorComponentB
Определения ItemBase.c:4920
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4858
bool IsActionTargetVisible()
Определения ItemBase.c:9196
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6050
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6339
bool m_IsBeingPlaced
Определения ItemBase.c:4901
int NameToID(string name)
Определения ItemBase.c:7683
void ~ItemBase()
Определения ItemBase.c:5580
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8546
void ClearStopItemSoundServer()
Определения ItemBase.c:9288
override string ChangeIntoOnDetach()
Определения ItemBase.c:6263
float m_VarWetMax
Определения ItemBase.c:4882
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6680
int GetLockType()
Определения ItemBase.c:8624
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9670
override float GetWet()
Определения ItemBase.c:8516
EffectSound m_SoundPlace
Определения ItemBase.c:9671
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8234
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8598
bool m_IsPlaceSound
Определения ItemBase.c:9674
override float GetWetMin()
Определения ItemBase.c:8526
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4974
override bool KindOf(string tag)
Определения ItemBase.c:7612
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:321
string GetDebugText()
Определения ModifierBase.c:71
PlayerBase GetPlayer()
Определения ModifierBase.c:51
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
EntityAI GetItem()
Определения RadialQuickbarMenu.c:37
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
void Debug()
Определения UniversalTemperatureSource.c:349
int GetID()
Определения ActionBase.c:1360
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:998
GetInputType()
Определения ActionBase.c:215
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
Определения AnalyticsManagerClient.c:77
proto native UIManager GetUIManager()
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native void GizmoSelectObject(Object object)
proto native bool ConfigIsExisting(string path)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native DayZPlayer GetPlayer()
proto native void GizmoSelectPhysics(Physics physics)
proto int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Global/game.c:1568
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local=false)
proto native void ObjectDelete(Object obj)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1280
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:541
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1275
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/Entities/Man.c:44
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
Определения ItemBase.c:15
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:469
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
override bool CanDisplayCargo()
Определения UndergroundStash.c:24
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override void SetActions()
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:412
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:424
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool IsClothing()
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto void Remove(func fn)
remove specific call from queue
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:64
proto native float GetDamage(string zoneName, string healthType)
UIScriptedMenu FindMenu(int id)
Returns menu with specific ID if it is open (see MenuID)
Определения UIManager.c:160
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/tools/Debug.c:816
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:100
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/constants.c:512
const int DEF_CHEMICAL
Определения 3_Game/constants.c:513
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:709
array< int > TIntArray
Определения EnScript.c:711
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/constants.c:808
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/constants.c:632
const int VARIABLE_CLEANNESS
Определения 3_Game/constants.c:635
const int VARIABLE_COLOR
Определения 3_Game/constants.c:634
const int VARIABLE_TEMPERATURE
Определения 3_Game/constants.c:630
const int VARIABLE_QUANTITY
Определения 3_Game/constants.c:628
const int VARIABLE_WET
Определения 3_Game/constants.c:631
const int LIQUID_NONE
Определения 3_Game/constants.c:529
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/constants.c:453
const int SAT_DEBUG_ACTION
Определения 3_Game/constants.c:454
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/tools/tools.c:8
proto native int GetColor()

Используется в InventoryItem::OnStoreSave().