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

◆ IsHeavyBehaviour()

override bool SpawnItemOnLocation::IsHeavyBehaviour ( )
protected

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

9144{
9145 override bool CanPutAsAttachment(EntityAI parent)
9146 {
9147 return true;
9148 }
9149};
9150
9151//const bool QUANTITY_DEBUG_REMOVE_ME = false;
9152
9153class ItemBase extends InventoryItem
9154{
9158
9160
9161 static int m_DebugActionsMask;
9163 // ============================================
9164 // Variable Manipulation System
9165 // ============================================
9166 // Quantity
9167
9168 float m_VarQuantity;
9169 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
9171 int m_VarQuantityMin;
9172 int m_VarQuantityMax;
9173 int m_Count;
9174 float m_VarStackMax;
9175 float m_StoreLoadedQuantity = float.LOWEST;
9176 // Wet
9177 float m_VarWet;
9178 float m_VarWetPrev;//for client to know wetness changed during synchronization
9179 float m_VarWetInit;
9180 float m_VarWetMin;
9181 float m_VarWetMax;
9182 // Cleanness
9183 int m_Cleanness;
9184 int m_CleannessInit;
9185 int m_CleannessMin;
9186 int m_CleannessMax;
9187 // impact sounds
9189 bool m_CanPlayImpactSound = true;
9190 float m_ImpactSpeed;
9192 //
9193 float m_HeatIsolation;
9194 float m_ItemModelLength;
9195 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
9197 int m_VarLiquidType;
9198 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
9199 int m_QuickBarBonus;
9200 bool m_IsBeingPlaced;
9201 bool m_IsHologram;
9202 bool m_IsTakeable;
9203 bool m_ThrowItemOnDrop;
9206 bool m_FixDamageSystemInit = false; //can be changed on storage version check
9207 bool can_this_be_combined; //Check if item can be combined
9208 bool m_CanThisBeSplit; //Check if item can be split
9209 bool m_IsStoreLoad = false;
9210 bool m_CanShowQuantity;
9211 bool m_HasQuantityBar;
9212 protected bool m_CanBeDigged;
9213 protected bool m_IsResultOfSplit
9214
9215 string m_SoundAttType;
9216 // items color variables
9221 //-------------------------------------------------------
9222
9223 // light source managing
9225
9229
9230 //==============================================
9231 // agent system
9232 private int m_AttachedAgents;
9233
9235 void TransferModifiers(PlayerBase reciever);
9236
9237
9238 // Weapons & suppressors particle effects
9243 static int m_LastRegisteredWeaponID = 0;
9244
9245 // Overheating effects
9247 float m_OverheatingShots;
9248 ref Timer m_CheckOverheating;
9249 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
9250 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
9251 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
9252 ref array <ref OverheatingParticle> m_OverheatingParticles;
9253
9255 protected bool m_HideSelectionsBySlot;
9256
9257 // Admin Log
9258 PluginAdminLog m_AdminLog;
9259
9260 // misc
9261 ref Timer m_PhysDropTimer;
9262
9263 // Attachment Locking variables
9264 ref array<int> m_CompatibleLocks;
9265 protected int m_LockType;
9266 protected ref EffectSound m_LockingSound;
9267 protected string m_LockSoundSet;
9268
9269 // ItemSoundHandler
9270 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
9271 protected int m_SoundSyncPlay; // id for sound to play
9272 protected int m_SoundSyncStop; // id for sound to stop
9274
9275 //temperature
9276 private float m_TemperaturePerQuantityWeight;
9277
9278 // -------------------------------------------------------------------------
9279 void ItemBase()
9280 {
9281 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
9285
9286 if (!GetGame().IsDedicatedServer())
9287 {
9288 if (HasMuzzle())
9289 {
9291
9293 {
9295 }
9296 }
9297
9299 m_ActionsInitialize = false;
9300 }
9301
9302 m_OldLocation = null;
9303
9304 if (GetGame().IsServer())
9305 {
9306 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
9307 }
9308
9309 if (ConfigIsExisting("headSelectionsToHide"))
9310 {
9312 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
9313 }
9314
9315 m_HideSelectionsBySlot = false;
9316 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
9317 {
9318 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
9319 }
9320
9321 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
9322
9323 m_IsResultOfSplit = false;
9324
9326 }
9327
9328 override void InitItemVariables()
9329 {
9330 super.InitItemVariables();
9331
9332 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
9333 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
9334 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
9335 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
9336 m_VarStackMax = ConfigGetFloat("varStackMax");
9337 m_Count = ConfigGetInt("count");
9338
9339 m_CanShowQuantity = ConfigGetBool("quantityShow");
9340 m_HasQuantityBar = ConfigGetBool("quantityBar");
9341
9342 m_CleannessInit = ConfigGetInt("varCleannessInit");
9344 m_CleannessMin = ConfigGetInt("varCleannessMin");
9345 m_CleannessMax = ConfigGetInt("varCleannessMax");
9346
9347 m_WantPlayImpactSound = false;
9348 m_ImpactSpeed = 0.0;
9349
9350 m_VarWetInit = ConfigGetFloat("varWetInit");
9352 m_VarWetMin = ConfigGetFloat("varWetMin");
9353 m_VarWetMax = ConfigGetFloat("varWetMax");
9354
9355 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
9356 if (IsLiquidContainer() && GetQuantity() != 0)
9358 m_IsBeingPlaced = false;
9359 m_IsHologram = false;
9360 m_IsTakeable = true;
9361 m_CanBeMovedOverride = false;
9365 m_CanBeDigged = ConfigGetBool("canBeDigged");
9366
9367 m_CompatibleLocks = new array<int>();
9368 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
9369 m_LockType = ConfigGetInt("lockType");
9370
9371 //Define if item can be split and set ability to be combined accordingly
9372 m_CanThisBeSplit = false;
9373 can_this_be_combined = false;
9374 if (ConfigIsExisting("canBeSplit"))
9375 {
9376 can_this_be_combined = ConfigGetBool("canBeSplit");
9378 }
9379
9380 m_ItemBehaviour = -1;
9381 if (ConfigIsExisting("itemBehaviour"))
9382 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
9383
9384 //RegisterNetSyncVariableInt("m_VariablesMask");
9385 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9386 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
9387 RegisterNetSyncVariableInt("m_VarLiquidType");
9388 RegisterNetSyncVariableInt("m_Cleanness",0,1);
9389
9390 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
9391 RegisterNetSyncVariableFloat("m_ImpactSpeed");
9392 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
9393
9394 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
9395 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
9396 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
9397 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
9398
9399 RegisterNetSyncVariableBool("m_IsBeingPlaced");
9400 RegisterNetSyncVariableBool("m_IsTakeable");
9401 RegisterNetSyncVariableBool("m_IsHologram");
9402
9403 InitItemSounds();
9405 {
9406 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
9407 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
9408 }
9409
9410 m_LockSoundSet = ConfigGetString("lockSoundSet");
9411
9413 if (ConfigIsExisting("temperaturePerQuantityWeight"))
9414 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
9415
9416 }
9417
9418 override int GetQuickBarBonus()
9419 {
9420 return m_QuickBarBonus;
9421 }
9422
9423 void InitializeActions()
9424 {
9426 if (!m_InputActionMap)
9427 {
9429 m_InputActionMap = iam;
9430 SetActions();
9432 }
9433 }
9434
9435 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
9436 {
9438 {
9439 m_ActionsInitialize = true;
9441 }
9442
9443 actions = m_InputActionMap.Get(action_input_type);
9444 }
9445
9446 void SetActions()
9447 {
9448 AddAction(ActionTakeItem);
9449 AddAction(ActionTakeItemToHands);
9450 AddAction(ActionWorldCraft);
9452 AddAction(ActionAttachWithSwitch);
9453 }
9454
9455 void SetActionAnimOverrides(); // Override action animation for specific item
9456
9457 void AddAction(typename actionName)
9458 {
9459 ActionBase action = ActionManagerBase.GetAction(actionName);
9460
9461 if (!action)
9462 {
9463 Debug.LogError("Action " + actionName + " dosn't exist!");
9464 return;
9465 }
9466
9467 typename ai = action.GetInputType();
9468 if (!ai)
9469 {
9470 m_ActionsInitialize = false;
9471 return;
9472 }
9473
9474 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9475 if (!action_array)
9476 {
9477 action_array = new array<ActionBase_Basic>;
9478 m_InputActionMap.Insert(ai, action_array);
9479 }
9480 if (LogManager.IsActionLogEnable())
9481 {
9482 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9483 }
9484
9485 if (action_array.Find(action) != -1)
9486 {
9487 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
9488 }
9489 else
9490 {
9491 action_array.Insert(action);
9492 }
9493 }
9494
9495 void RemoveAction(typename actionName)
9496 {
9497 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9498 ActionBase action = player.GetActionManager().GetAction(actionName);
9499 typename ai = action.GetInputType();
9500 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9501
9502 if (action_array)
9503 {
9504 action_array.RemoveItem(action);
9505 }
9506 }
9507
9508 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
9509 // Set -1 for params which should stay in default state
9510 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
9511 {
9512 ActionOverrideData overrideData = new ActionOverrideData();
9513 overrideData.m_CommandUID = commandUID;
9514 overrideData.m_CommandUIDProne = commandUIDProne;
9515 overrideData.m_StanceMask = stanceMask;
9516
9517 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
9518 if (!actionMap) // create new map of action > overidables map
9519 {
9520 actionMap = new TActionAnimOverrideMap();
9521 m_ItemActionOverrides.Insert(action, actionMap);
9522 }
9523
9524 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9525
9526 }
9527
9528 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9529
9530 ScriptedLightBase GetLight();
9531
9532 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9533 void LoadParticleConfigOnFire(int id)
9534 {
9535 if (!m_OnFireEffect)
9537
9540
9541 string config_to_search = "CfgVehicles";
9542 string muzzle_owner_config;
9543
9544 if (!m_OnFireEffect.Contains(id))
9545 {
9546 if (IsInherited(Weapon))
9547 config_to_search = "CfgWeapons";
9548
9549 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9550
9551 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9552
9553 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
9554
9555 if (config_OnFire_subclass_count > 0)
9556 {
9557 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9558
9559 for (int i = 0; i < config_OnFire_subclass_count; i++)
9560 {
9561 string particle_class = "";
9562 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
9563 string config_OnFire_entry = config_OnFire_class + particle_class;
9564 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9565 WPOF_array.Insert(WPOF);
9566 }
9567
9568
9569 m_OnFireEffect.Insert(id, WPOF_array);
9570 }
9571 }
9572
9573 if (!m_OnBulletCasingEjectEffect.Contains(id))
9574 {
9575 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9576 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9577
9578 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9579
9580 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9581
9582 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9583 {
9584 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9585
9586 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9587 {
9588 string particle_class2 = "";
9589 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9590 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9591 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9592 WPOBE_array.Insert(WPOBE);
9593 }
9594
9595
9596 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9597 }
9598 }
9599 }
9600
9601 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9603 {
9606
9607 if (!m_OnOverheatingEffect.Contains(id))
9608 {
9609 string config_to_search = "CfgVehicles";
9610
9611 if (IsInherited(Weapon))
9612 config_to_search = "CfgWeapons";
9613
9614 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9615 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9616
9617 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
9618 {
9619
9620 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9621
9623 {
9624 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9625 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9626 Error(error);
9627 return;
9628 }
9629
9630 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9631 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9632
9633
9634
9635 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
9636 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9637
9638 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9639 {
9640 string particle_class = "";
9641 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9642 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9643 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
9644
9645 if (entry_type == CT_CLASS)
9646 {
9647 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9648 WPOOH_array.Insert(WPOF);
9649 }
9650 }
9651
9652
9653 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9654 }
9655 }
9656 }
9657
9658 float GetOverheatingValue()
9659 {
9660 return m_OverheatingShots;
9661 }
9662
9663 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9664 {
9665 if (m_MaxOverheatingValue > 0)
9666 {
9668
9669 if (!m_CheckOverheating)
9671
9673 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9674
9675 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9676 }
9677 }
9678
9679 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9680 {
9682 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9683
9685 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9686
9688 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9689
9691 {
9693 }
9694 }
9695
9697 {
9699 }
9700
9701 void OnOverheatingDecay()
9702 {
9703 if (m_MaxOverheatingValue > 0)
9704 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9705 else
9707
9708 if (m_OverheatingShots <= 0)
9709 {
9712 }
9713 else
9714 {
9715 if (!m_CheckOverheating)
9717
9719 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9720 }
9721
9722 CheckOverheating(this, "", this);
9723 }
9724
9725 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9726 {
9728 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9729 }
9730
9731 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9732 {
9734 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9736 }
9737
9738 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9739 {
9741 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9742 }
9743
9744 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9745 {
9747 m_OverheatingParticles = new array<ref OverheatingParticle>;
9748
9749 OverheatingParticle OP = new OverheatingParticle();
9750 OP.RegisterParticle(p);
9751 OP.SetOverheatingLimitMin(min_heat_coef);
9752 OP.SetOverheatingLimitMax(max_heat_coef);
9753 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9754
9755 m_OverheatingParticles.Insert(OP);
9756 }
9757
9758 float GetOverheatingCoef()
9759 {
9760 if (m_MaxOverheatingValue > 0)
9762
9763 return -1;
9764 }
9765
9767 {
9769 {
9770 float overheat_coef = GetOverheatingCoef();
9771 int count = m_OverheatingParticles.Count();
9772
9773 for (int i = count; i > 0; --i)
9774 {
9775 int id = i - 1;
9776 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9777 Particle p = OP.GetParticle();
9778
9779 float overheat_min = OP.GetOverheatingLimitMin();
9780 float overheat_max = OP.GetOverheatingLimitMax();
9781
9782 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9783 {
9784 if (p)
9785 {
9786 p.Stop();
9787 OP.RegisterParticle(null);
9788 }
9789 }
9790 }
9791 }
9792 }
9793
9795 {
9797 {
9798 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9799 {
9800 int id = i - 1;
9801 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9802
9803 if (OP)
9804 {
9805 Particle p = OP.GetParticle();
9806
9807 if (p)
9808 {
9809 p.Stop();
9810 }
9811
9812 delete OP;
9813 }
9814 }
9815
9816 m_OverheatingParticles.Clear();
9818 }
9819 }
9820
9822 float GetInfectionChance(int system = 0, Param param = null)
9823 {
9824 return 0.0;
9825 }
9826
9827
9828 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9829 {
9830 return 250;//default value
9831 }
9832
9833 float GetFilterDamageRatio()
9834 {
9835 return 0;
9836 }
9837
9839 bool HasMuzzle()
9840 {
9841 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9842 return true;
9843
9844 return false;
9845 }
9846
9848 int GetMuzzleID()
9849 {
9850 if (!m_WeaponTypeToID)
9852
9853 if (m_WeaponTypeToID.Contains(GetType()))
9854 {
9855 return m_WeaponTypeToID.Get(GetType());
9856 }
9857 else
9858 {
9859 // Register new weapon ID
9861 }
9862
9864 }
9865
9872 {
9873 return -1;
9874 }
9875
9876
9877
9878 // -------------------------------------------------------------------------
9879 void ~ItemBase()
9880 {
9881 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
9882 {
9883 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9884 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9885
9886 if (r_index >= 0)
9887 {
9888 InventoryLocation r_il = new InventoryLocation;
9889 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9890
9891 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9892 int r_type = r_il.GetType();
9893 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9894 {
9895 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9896 }
9897 else if (r_type == InventoryLocationType.ATTACHMENT)
9898 {
9899 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9900 }
9901
9902 }
9903
9904 player.GetHumanInventory().ClearUserReservedLocation(this);
9905 }
9906
9907 if (m_LockingSound)
9908 SEffectManager.DestroyEffect(m_LockingSound);
9909 }
9910
9911
9912
9913 // -------------------------------------------------------------------------
9914 static int GetDebugActionsMask()
9915 {
9916 return ItemBase.m_DebugActionsMask;
9917 }
9918
9919 static bool HasDebugActionsMask(int mask)
9920 {
9921 return ItemBase.m_DebugActionsMask & mask;
9922 }
9923
9924 static void SetDebugActionsMask(int mask)
9925 {
9926 ItemBase.m_DebugActionsMask = mask;
9927 }
9928
9929 static void AddDebugActionsMask(int mask)
9930 {
9931 ItemBase.m_DebugActionsMask |= mask;
9932 }
9933
9934 static void RemoveDebugActionsMask(int mask)
9935 {
9936 ItemBase.m_DebugActionsMask &= ~mask;
9937 }
9938
9939 static void ToggleDebugActionsMask(int mask)
9940 {
9941 if (HasDebugActionsMask(mask))
9942 {
9944 }
9945 else
9946 {
9947 AddDebugActionsMask(mask);
9948 }
9949 }
9950
9951 // -------------------------------------------------------------------------
9952 void SetCEBasedQuantity()
9953 {
9954 if (GetEconomyProfile())
9955 {
9956 float q_max = GetEconomyProfile().GetQuantityMax();
9957 if (q_max > 0)
9958 {
9959 float q_min = GetEconomyProfile().GetQuantityMin();
9960 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9961
9962 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9963 {
9964 ComponentEnergyManager comp = GetCompEM();
9965 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
9966 {
9967 comp.SetEnergy0To1(quantity_randomized);
9968 }
9969 }
9970 else if (HasQuantity())
9971 {
9972 SetQuantityNormalized(quantity_randomized, false);
9973 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9974 }
9975
9976 }
9977 }
9978 }
9979
9981 void LockToParent()
9982 {
9983 EntityAI parent = GetHierarchyParent();
9984
9985 if (parent)
9986 {
9987 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9988 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9989 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9990 }
9991 }
9992
9994 void UnlockFromParent()
9995 {
9996 EntityAI parent = GetHierarchyParent();
9997
9998 if (parent)
9999 {
10000 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
10001 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
10002 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
10003 }
10004 }
10005
10006 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
10007 {
10008 /*
10009 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
10010 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
10011 */
10012 ItemBase item2 = ItemBase.Cast(entity2);
10013
10014 if (GetGame().IsClient())
10015 {
10016 if (ScriptInputUserData.CanStoreInputUserData())
10017 {
10018 ScriptInputUserData ctx = new ScriptInputUserData;
10020 ctx.Write(-1);
10021 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10022 ctx.Write(i1);
10023 ctx.Write(item2);
10024 ctx.Write(use_stack_max);
10025 ctx.Write(-1);
10026 ctx.Send();
10027
10028 if (IsCombineAll(item2, use_stack_max))
10029 {
10030 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
10031 }
10032 }
10033 }
10034 else if (!GetGame().IsMultiplayer())
10035 {
10036 CombineItems(item2, use_stack_max);
10037 }
10038 }
10039
10040 bool IsLiquidPresent()
10041 {
10042 return (GetLiquidType() != 0 && HasQuantity());
10043 }
10044
10045 bool IsLiquidContainer()
10046 {
10047 return m_LiquidContainerMask != 0;
10048 }
10049
10051 {
10052 return m_LiquidContainerMask;
10053 }
10054
10055 bool IsBloodContainer()
10056 {
10057 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
10058 return false;
10059 }
10060
10061 bool IsNVG()
10062 {
10063 return false;
10064 }
10065
10068 bool IsExplosive()
10069 {
10070 return false;
10071 }
10072
10074 {
10075 return "";
10076 }
10077
10079
10080 bool IsLightSource()
10081 {
10082 return false;
10083 }
10084
10086 {
10087 return true;
10088 }
10089
10090 //--- ACTION CONDITIONS
10091 //direction
10092 bool IsFacingPlayer(PlayerBase player, string selection)
10093 {
10094 return true;
10095 }
10096
10097 bool IsPlayerInside(PlayerBase player, string selection)
10098 {
10099 return true;
10100 }
10101
10102 override bool CanObstruct()
10103 {
10104 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10105 return !player || !IsPlayerInside(player, "");
10106 }
10107
10108 override bool IsBeingPlaced()
10109 {
10110 return m_IsBeingPlaced;
10111 }
10112
10113 void SetIsBeingPlaced(bool is_being_placed)
10114 {
10115 m_IsBeingPlaced = is_being_placed;
10116 if (!is_being_placed)
10118 SetSynchDirty();
10119 }
10120
10121 //server-side
10122 void OnEndPlacement() {}
10123
10124 override bool IsHologram()
10125 {
10126 return m_IsHologram;
10127 }
10128
10129 bool CanBeDigged()
10130 {
10131 return m_CanBeDigged;
10132 }
10133
10135 {
10136 return 1;
10137 }
10138
10139 bool CanMakeGardenplot()
10140 {
10141 return false;
10142 }
10143
10144 void SetIsHologram(bool is_hologram)
10145 {
10146 m_IsHologram = is_hologram;
10147 SetSynchDirty();
10148 }
10149 /*
10150 protected float GetNutritionalEnergy()
10151 {
10152 Edible_Base edible = Edible_Base.Cast(this);
10153 return edible.GetFoodEnergy();
10154 }
10155
10156 protected float GetNutritionalWaterContent()
10157 {
10158 Edible_Base edible = Edible_Base.Cast(this);
10159 return edible.GetFoodWater();
10160 }
10161
10162 protected float GetNutritionalIndex()
10163 {
10164 Edible_Base edible = Edible_Base.Cast(this);
10165 return edible.GetFoodNutritionalIndex();
10166 }
10167
10168 protected float GetNutritionalFullnessIndex()
10169 {
10170 Edible_Base edible = Edible_Base.Cast(this);
10171 return edible.GetFoodTotalVolume();
10172 }
10173
10174 protected float GetNutritionalToxicity()
10175 {
10176 Edible_Base edible = Edible_Base.Cast(this);
10177 return edible.GetFoodToxicity();
10178
10179 }
10180 */
10181
10182
10183 // -------------------------------------------------------------------------
10184 override void OnMovedInsideCargo(EntityAI container)
10185 {
10186 super.OnMovedInsideCargo(container);
10187
10188 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10189 }
10190
10191 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10192 {
10193 super.EEItemLocationChanged(oldLoc,newLoc);
10194
10195 PlayerBase new_player = null;
10196 PlayerBase old_player = null;
10197
10198 if (newLoc.GetParent())
10199 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
10200
10201 if (oldLoc.GetParent())
10202 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
10203
10204 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
10205 {
10206 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
10207
10208 if (r_index >= 0)
10209 {
10210 InventoryLocation r_il = new InventoryLocation;
10211 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10212
10213 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10214 int r_type = r_il.GetType();
10215 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10216 {
10217 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10218 }
10219 else if (r_type == InventoryLocationType.ATTACHMENT)
10220 {
10221 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10222 }
10223
10224 }
10225 }
10226
10227 if (newLoc.GetType() == InventoryLocationType.HANDS)
10228 {
10229 if (new_player)
10230 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
10231
10232 if (new_player == old_player)
10233 {
10234
10235 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
10236 {
10237 if (oldLoc.GetType() == InventoryLocationType.CARGO)
10238 {
10239 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
10240 {
10241 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10242 }
10243 }
10244 else
10245 {
10246 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10247 }
10248 }
10249
10250 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
10251 {
10252 int type = oldLoc.GetType();
10253 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
10254 {
10255 oldLoc.GetParent().GetOnSetLock().Invoke(this);
10256 }
10257 else if (type == InventoryLocationType.ATTACHMENT)
10258 {
10259 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
10260 }
10261 }
10262 if (!m_OldLocation)
10263 {
10264 m_OldLocation = new InventoryLocation;
10265 }
10266 m_OldLocation.Copy(oldLoc);
10267 }
10268 else
10269 {
10270 if (m_OldLocation)
10271 {
10272 m_OldLocation.Reset();
10273 }
10274 }
10275
10277 }
10278 else
10279 {
10280 if (new_player)
10281 {
10282 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
10283 if (res_index >= 0)
10284 {
10285 InventoryLocation il = new InventoryLocation;
10286 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
10287 ItemBase it = ItemBase.Cast(il.GetItem());
10288 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
10289 int rel_type = il.GetType();
10290 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
10291 {
10292 il.GetParent().GetOnReleaseLock().Invoke(it);
10293 }
10294 else if (rel_type == InventoryLocationType.ATTACHMENT)
10295 {
10296 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
10297 }
10298 //it.GetOnReleaseLock().Invoke(it);
10299 }
10300 }
10301 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
10302 {
10303 //ThrowPhysically(old_player, vector.Zero);
10304 m_ThrowItemOnDrop = false;
10305 }
10306
10307 if (m_OldLocation)
10308 {
10309 m_OldLocation.Reset();
10310 }
10311 }
10312 }
10313
10314 override void EOnContact(IEntity other, Contact extra)
10315 {
10317 {
10318 int liquidType = -1;
10319 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
10320 if (impactSpeed > 0.0)
10321 {
10322 m_ImpactSpeed = impactSpeed;
10323 #ifndef SERVER
10324 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10325 #else
10326 m_WantPlayImpactSound = true;
10327 SetSynchDirty();
10328 #endif
10329 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
10330 }
10331 }
10332
10333 #ifdef SERVER
10334 if (GetCompEM() && GetCompEM().IsPlugged())
10335 {
10336 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
10337 GetCompEM().UnplugThis();
10338 }
10339 #endif
10340 }
10341
10342 void RefreshPhysics();
10343
10344 override void OnCreatePhysics()
10345 {
10347 }
10348
10349 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10350 {
10351
10352 }
10353 // -------------------------------------------------------------------------
10354 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
10355 {
10356 super.OnItemLocationChanged(old_owner, new_owner);
10357
10358 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
10359 PlayerBase playerNew = PlayerBase.Cast(new_owner);
10360
10361 if (!relatedPlayer && playerNew)
10362 relatedPlayer = playerNew;
10363
10364 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
10365 {
10366 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
10367 if (actionMgr)
10368 {
10369 ActionBase currentAction = actionMgr.GetRunningAction();
10370 if (currentAction)
10371 currentAction.OnItemLocationChanged(this);
10372 }
10373 }
10374
10375 Man ownerPlayerOld = null;
10376 Man ownerPlayerNew = null;
10377
10378 if (old_owner)
10379 {
10380 if (old_owner.IsMan())
10381 {
10382 ownerPlayerOld = Man.Cast(old_owner);
10383 }
10384 else
10385 {
10386 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
10387 }
10388 }
10389 else
10390 {
10391 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
10392 {
10393 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
10394
10395 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
10396 {
10397 GetCompEM().UnplugThis();
10398 }
10399 }
10400 }
10401
10402 if (new_owner)
10403 {
10404 if (new_owner.IsMan())
10405 {
10406 ownerPlayerNew = Man.Cast(new_owner);
10407 }
10408 else
10409 {
10410 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
10411 }
10412 }
10413
10414 if (ownerPlayerOld != ownerPlayerNew)
10415 {
10416 if (ownerPlayerOld)
10417 {
10418 array<EntityAI> subItemsExit = new array<EntityAI>;
10419 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
10420 for (int i = 0; i < subItemsExit.Count(); i++)
10421 {
10422 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
10423 itemExit.OnInventoryExit(ownerPlayerOld);
10424 }
10425 }
10426
10427 if (ownerPlayerNew)
10428 {
10429 array<EntityAI> subItemsEnter = new array<EntityAI>;
10430 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
10431 for (int j = 0; j < subItemsEnter.Count(); j++)
10432 {
10433 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
10434 itemEnter.OnInventoryEnter(ownerPlayerNew);
10435 }
10436 }
10437 }
10438 else if (ownerPlayerNew != null)
10439 {
10440 PlayerBase nplayer;
10441 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
10442 {
10443 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10444 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10445 for (int k = 0; k < subItemsUpdate.Count(); k++)
10446 {
10447 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10448 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10449 }
10450 }
10451 }
10452
10453 if (old_owner)
10454 old_owner.OnChildItemRemoved(this);
10455 if (new_owner)
10456 new_owner.OnChildItemReceived(this);
10457 }
10458
10459 // -------------------------------------------------------------------------------
10460 override void EEDelete(EntityAI parent)
10461 {
10462 super.EEDelete(parent);
10463 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10464 if (player)
10465 {
10466 OnInventoryExit(player);
10467
10468 if (player.IsAlive())
10469 {
10470 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10471 if (r_index >= 0)
10472 {
10473 InventoryLocation r_il = new InventoryLocation;
10474 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10475
10476 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10477 int r_type = r_il.GetType();
10478 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10479 {
10480 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10481 }
10482 else if (r_type == InventoryLocationType.ATTACHMENT)
10483 {
10484 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10485 }
10486
10487 }
10488
10489 player.RemoveQuickBarEntityShortcut(this);
10490 }
10491 }
10492 }
10493 // -------------------------------------------------------------------------------
10494 override void EEKilled(Object killer)
10495 {
10496 super.EEKilled(killer);
10497
10499 if (killer && killer.IsFireplace() && CanExplodeInFire())
10500 {
10501 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
10502 {
10503 if (IsMagazine())
10504 {
10505 if (Magazine.Cast(this).GetAmmoCount() > 0)
10506 {
10507 ExplodeAmmo();
10508 }
10509 }
10510 else
10511 {
10512 Explode(DamageType.EXPLOSION);
10513 }
10514 }
10515 }
10516 }
10517
10518 override void OnWasAttached(EntityAI parent, int slot_id)
10519 {
10520 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10521
10522 super.OnWasAttached(parent, slot_id);
10523
10524 if (HasQuantity())
10525 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10526
10527 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
10528 }
10529
10530 override void OnWasDetached(EntityAI parent, int slot_id)
10531 {
10532 super.OnWasDetached(parent, slot_id);
10533
10534 if (HasQuantity())
10535 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10536 }
10537
10538 override string ChangeIntoOnAttach(string slot)
10539 {
10540 int idx;
10541 TStringArray inventory_slots = new TStringArray;
10542 TStringArray attach_types = new TStringArray;
10543
10544 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10545 if (inventory_slots.Count() < 1) //is string
10546 {
10547 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10548 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10549 }
10550 else //is array
10551 {
10552 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10553 }
10554
10555 idx = inventory_slots.Find(slot);
10556 if (idx < 0)
10557 return "";
10558
10559 return attach_types.Get(idx);
10560 }
10561
10562 override string ChangeIntoOnDetach()
10563 {
10564 int idx = -1;
10565 string slot;
10566
10567 TStringArray inventory_slots = new TStringArray;
10568 TStringArray detach_types = new TStringArray;
10569
10570 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10571 if (inventory_slots.Count() < 1) //is string
10572 {
10573 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10574 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10575 }
10576 else //is array
10577 {
10578 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10579 if (detach_types.Count() < 1)
10580 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10581 }
10582
10583 for (int i = 0; i < inventory_slots.Count(); i++)
10584 {
10585 slot = inventory_slots.Get(i);
10586 }
10587
10588 if (slot != "")
10589 {
10590 if (detach_types.Count() == 1)
10591 idx = 0;
10592 else
10593 idx = inventory_slots.Find(slot);
10594 }
10595 if (idx < 0)
10596 return "";
10597
10598 return detach_types.Get(idx);
10599 }
10600
10601 void ExplodeAmmo()
10602 {
10603 //timer
10604 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10605
10606 //min/max time
10607 float min_time = 1;
10608 float max_time = 3;
10609 float delay = Math.RandomFloat(min_time, max_time);
10610
10611 explode_timer.Run(delay, this, "DoAmmoExplosion");
10612 }
10613
10614 void DoAmmoExplosion()
10615 {
10616 Magazine magazine = Magazine.Cast(this);
10617 int pop_sounds_count = 6;
10618 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10619
10620 //play sound
10621 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10622 string sound_name = pop_sounds[ sound_idx ];
10623 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
10624
10625 //remove ammo count
10626 magazine.ServerAddAmmoCount(-1);
10627
10628 //if condition then repeat -> ExplodeAmmo
10629 float min_temp_to_explode = 100; //min temperature for item to explode
10630
10631 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10632 {
10633 ExplodeAmmo();
10634 }
10635 }
10636
10637 // -------------------------------------------------------------------------------
10638 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10639 {
10640 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10641
10642 const int CHANCE_DAMAGE_CARGO = 4;
10643 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10644 const int CHANCE_DAMAGE_NOTHING = 2;
10645
10646 if (IsClothing() || IsContainer() || IsItemTent())
10647 {
10648 float dmg = damageResult.GetDamage("","Health") * -0.5;
10649 int chances;
10650 int rnd;
10651
10652 if (GetInventory().GetCargo())
10653 {
10654 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10655 rnd = Math.RandomInt(0,chances);
10656
10657 if (rnd < CHANCE_DAMAGE_CARGO)
10658 {
10659 DamageItemInCargo(dmg);
10660 }
10661 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10662 {
10664 }
10665 }
10666 else
10667 {
10668 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10669 rnd = Math.RandomInt(0,chances);
10670
10671 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10672 {
10674 }
10675 }
10676 }
10677 }
10678
10679 bool DamageItemInCargo(float damage)
10680 {
10681 if (GetInventory().GetCargo())
10682 {
10683 int item_count = GetInventory().GetCargo().GetItemCount();
10684 if (item_count > 0)
10685 {
10686 int random_pick = Math.RandomInt(0, item_count);
10687 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
10688 if (!item.IsExplosive())
10689 {
10690 item.AddHealth("","",damage);
10691 return true;
10692 }
10693 }
10694 }
10695 return false;
10696 }
10697
10698 bool DamageItemAttachments(float damage)
10699 {
10700 int attachment_count = GetInventory().AttachmentCount();
10701 if (attachment_count > 0)
10702 {
10703 int random_pick = Math.RandomInt(0, attachment_count);
10704 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
10705 if (!attachment.IsExplosive())
10706 {
10707 attachment.AddHealth("","",damage);
10708 return true;
10709 }
10710 }
10711 return false;
10712 }
10713
10714 override bool IsSplitable()
10715 {
10716 return m_CanThisBeSplit;
10717 }
10718 //----------------
10719 override bool CanBeSplit()
10720 {
10721 if (IsSplitable() && (GetQuantity() > 1))
10722 return GetInventory().CanRemoveEntity();
10723
10724 return false;
10725 }
10726
10727 protected bool ShouldSplitQuantity(float quantity)
10728 {
10729 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10730 if (!IsSplitable())
10731 return false;
10732
10733 // nothing to split?
10734 if (GetQuantity() <= 1)
10735 return false;
10736
10737 // check if we should re-use the item instead of creating a new copy?
10738 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10739 int delta = GetQuantity() - quantity;
10740 if (delta == 0)
10741 return false;
10742
10743 // valid to split
10744 return true;
10745 }
10746
10747 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10748 {
10749 if (GetGame().IsClient())
10750 {
10751 if (ScriptInputUserData.CanStoreInputUserData())
10752 {
10753 ScriptInputUserData ctx = new ScriptInputUserData;
10755 ctx.Write(1);
10756 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10757 ctx.Write(i1);
10758 ctx.Write(destination_entity);
10759 ctx.Write(true);
10760 ctx.Write(slot_id);
10761 ctx.Send();
10762 }
10763 }
10764 else if (!GetGame().IsMultiplayer())
10765 {
10766 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
10767 }
10768 }
10769
10770 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10771 {
10772 float split_quantity_new;
10773 ItemBase new_item;
10774 float quantity = GetQuantity();
10775 float stack_max = GetTargetQuantityMax(slot_id);
10776 InventoryLocation loc = new InventoryLocation;
10777
10778 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10779 {
10780 if (stack_max <= GetQuantity())
10781 split_quantity_new = stack_max;
10782 else
10783 split_quantity_new = GetQuantity();
10784
10785 if (ShouldSplitQuantity(split_quantity_new))
10786 {
10787 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10788 if (new_item)
10789 {
10790 new_item.SetResultOfSplit(true);
10791 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10792 AddQuantity(-split_quantity_new, false, true);
10793 new_item.SetQuantity(split_quantity_new, false, true);
10794 }
10795 }
10796 }
10797 else if (destination_entity && slot_id == -1)
10798 {
10799 if (quantity > stack_max)
10800 split_quantity_new = stack_max;
10801 else
10802 split_quantity_new = quantity;
10803
10804 if (ShouldSplitQuantity(split_quantity_new))
10805 {
10806 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10807 {
10808 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10809 new_item = ItemBase.Cast(o);
10810 }
10811
10812 if (new_item)
10813 {
10814 new_item.SetResultOfSplit(true);
10815 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10816 AddQuantity(-split_quantity_new, false, true);
10817 new_item.SetQuantity(split_quantity_new, false, true);
10818 }
10819 }
10820 }
10821 else
10822 {
10823 if (stack_max != 0)
10824 {
10825 if (stack_max < GetQuantity())
10826 {
10827 split_quantity_new = GetQuantity() - stack_max;
10828 }
10829
10830 if (split_quantity_new == 0)
10831 {
10832 if (!GetGame().IsMultiplayer())
10833 player.PhysicalPredictiveDropItem(this);
10834 else
10835 player.ServerDropEntity(this);
10836 return;
10837 }
10838
10839 if (ShouldSplitQuantity(split_quantity_new))
10840 {
10841 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10842
10843 if (new_item)
10844 {
10845 new_item.SetResultOfSplit(true);
10846 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10847 SetQuantity(split_quantity_new, false, true);
10848 new_item.SetQuantity(stack_max, false, true);
10849 new_item.PlaceOnSurface();
10850 }
10851 }
10852 }
10853 }
10854 }
10855
10856 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10857 {
10858 float split_quantity_new;
10859 ItemBase new_item;
10860 float quantity = GetQuantity();
10861 float stack_max = GetTargetQuantityMax(slot_id);
10862 InventoryLocation loc = new InventoryLocation;
10863
10864 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10865 {
10866 if (stack_max <= GetQuantity())
10867 split_quantity_new = stack_max;
10868 else
10869 split_quantity_new = GetQuantity();
10870
10871 if (ShouldSplitQuantity(split_quantity_new))
10872 {
10873 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10874 if (new_item)
10875 {
10876 new_item.SetResultOfSplit(true);
10877 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10878 AddQuantity(-split_quantity_new, false, true);
10879 new_item.SetQuantity(split_quantity_new, false, true);
10880 }
10881 }
10882 }
10883 else if (destination_entity && slot_id == -1)
10884 {
10885 if (quantity > stack_max)
10886 split_quantity_new = stack_max;
10887 else
10888 split_quantity_new = quantity;
10889
10890 if (ShouldSplitQuantity(split_quantity_new))
10891 {
10892 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10893 {
10894 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10895 new_item = ItemBase.Cast(o);
10896 }
10897
10898 if (new_item)
10899 {
10900 new_item.SetResultOfSplit(true);
10901 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10902 AddQuantity(-split_quantity_new, false, true);
10903 new_item.SetQuantity(split_quantity_new, false, true);
10904 }
10905 }
10906 }
10907 else
10908 {
10909 if (stack_max != 0)
10910 {
10911 if (stack_max < GetQuantity())
10912 {
10913 split_quantity_new = GetQuantity() - stack_max;
10914 }
10915
10916 if (ShouldSplitQuantity(split_quantity_new))
10917 {
10918 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10919
10920 if (new_item)
10921 {
10922 new_item.SetResultOfSplit(true);
10923 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10924 SetQuantity(split_quantity_new, false, true);
10925 new_item.SetQuantity(stack_max, false, true);
10926 new_item.PlaceOnSurface();
10927 }
10928 }
10929 }
10930 }
10931 }
10932
10933 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10934 {
10935 if (GetGame().IsClient())
10936 {
10937 if (ScriptInputUserData.CanStoreInputUserData())
10938 {
10939 ScriptInputUserData ctx = new ScriptInputUserData;
10941 ctx.Write(4);
10942 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10943 ctx.Write(thiz);
10944 dst.WriteToContext(ctx);
10945 ctx.Send();
10946 }
10947 }
10948 else if (!GetGame().IsMultiplayer())
10949 {
10951 }
10952 }
10953
10954 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10955 {
10956 if (GetGame().IsClient())
10957 {
10958 if (ScriptInputUserData.CanStoreInputUserData())
10959 {
10960 ScriptInputUserData ctx = new ScriptInputUserData;
10962 ctx.Write(2);
10963 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10964 ctx.Write(dummy);
10965 ctx.Write(destination_entity);
10966 ctx.Write(true);
10967 ctx.Write(idx);
10968 ctx.Write(row);
10969 ctx.Write(col);
10970 ctx.Send();
10971 }
10972 }
10973 else if (!GetGame().IsMultiplayer())
10974 {
10975 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10976 }
10977 }
10978
10979 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10980 {
10982 }
10983
10984 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10985 {
10986 float quantity = GetQuantity();
10987 float split_quantity_new;
10988 ItemBase new_item;
10989 if (dst.IsValid())
10990 {
10991 int slot_id = dst.GetSlot();
10992 float stack_max = GetTargetQuantityMax(slot_id);
10993
10994 if (quantity > stack_max)
10995 split_quantity_new = stack_max;
10996 else
10997 split_quantity_new = quantity;
10998
10999 if (ShouldSplitQuantity(split_quantity_new))
11000 {
11001 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
11002
11003 if (new_item)
11004 {
11005 new_item.SetResultOfSplit(true);
11006 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11007 AddQuantity(-split_quantity_new, false, true);
11008 new_item.SetQuantity(split_quantity_new, false, true);
11009 }
11010
11011 return new_item;
11012 }
11013 }
11014
11015 return null;
11016 }
11017
11018 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
11019 {
11020 float quantity = GetQuantity();
11021 float split_quantity_new;
11022 ItemBase new_item;
11023 if (destination_entity)
11024 {
11025 float stackable = GetTargetQuantityMax();
11026 if (quantity > stackable)
11027 split_quantity_new = stackable;
11028 else
11029 split_quantity_new = quantity;
11030
11031 if (ShouldSplitQuantity(split_quantity_new))
11032 {
11033 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
11034 if (new_item)
11035 {
11036 new_item.SetResultOfSplit(true);
11037 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11038 AddQuantity(-split_quantity_new, false, true);
11039 new_item.SetQuantity(split_quantity_new, false, true);
11040 }
11041 }
11042 }
11043 }
11044
11045 void SplitIntoStackMaxHandsClient(PlayerBase player)
11046 {
11047 if (GetGame().IsClient())
11048 {
11049 if (ScriptInputUserData.CanStoreInputUserData())
11050 {
11051 ScriptInputUserData ctx = new ScriptInputUserData;
11053 ctx.Write(3);
11054 ItemBase i1 = this; // @NOTE: workaround for correct serialization
11055 ctx.Write(i1);
11056 ItemBase destination_entity = this;
11057 ctx.Write(destination_entity);
11058 ctx.Write(true);
11059 ctx.Write(0);
11060 ctx.Send();
11061 }
11062 }
11063 else if (!GetGame().IsMultiplayer())
11064 {
11065 SplitIntoStackMaxHands(player);
11066 }
11067 }
11068
11069 void SplitIntoStackMaxHands(PlayerBase player)
11070 {
11071 float quantity = GetQuantity();
11072 float split_quantity_new;
11073 ref ItemBase new_item;
11074 if (player)
11075 {
11076 float stackable = GetTargetQuantityMax();
11077 if (quantity > stackable)
11078 split_quantity_new = stackable;
11079 else
11080 split_quantity_new = quantity;
11081
11082 if (ShouldSplitQuantity(split_quantity_new))
11083 {
11084 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
11085 new_item = ItemBase.Cast(in_hands);
11086 if (new_item)
11087 {
11088 new_item.SetResultOfSplit(true);
11089 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11090 AddQuantity(-split_quantity_new, false, true);
11091 new_item.SetQuantity(split_quantity_new, false, true);
11092 }
11093 }
11094 }
11095 }
11096
11097 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
11098 {
11099 float quantity = GetQuantity();
11100 float split_quantity_new = Math.Floor(quantity * 0.5);
11101
11102 if (!ShouldSplitQuantity(split_quantity_new))
11103 return;
11104
11105 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
11106
11107 if (new_item)
11108 {
11109 if (new_item.GetQuantityMax() < split_quantity_new)
11110 {
11111 split_quantity_new = new_item.GetQuantityMax();
11112 }
11113
11114 new_item.SetResultOfSplit(true);
11115 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11116
11117 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
11118 {
11119 AddQuantity(-1, false, true);
11120 new_item.SetQuantity(1, false, true);
11121 }
11122 else
11123 {
11124 AddQuantity(-split_quantity_new, false, true);
11125 new_item.SetQuantity(split_quantity_new, false, true);
11126 }
11127 }
11128 }
11129
11130 void SplitItem(PlayerBase player)
11131 {
11132 float quantity = GetQuantity();
11133 float split_quantity_new = Math.Floor(quantity / 2);
11134
11135 if (!ShouldSplitQuantity(split_quantity_new))
11136 return;
11137
11138 InventoryLocation invloc = new InventoryLocation;
11139 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
11140
11141 ItemBase new_item;
11142 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
11143
11144 if (new_item)
11145 {
11146 if (new_item.GetQuantityMax() < split_quantity_new)
11147 {
11148 split_quantity_new = new_item.GetQuantityMax();
11149 }
11150 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
11151 {
11152 AddQuantity(-1, false, true);
11153 new_item.SetQuantity(1, false, true);
11154 }
11155 else if (split_quantity_new > 1)
11156 {
11157 AddQuantity(-split_quantity_new, false, true);
11158 new_item.SetQuantity(split_quantity_new, false, true);
11159 }
11160 }
11161 }
11162
11164 void OnQuantityChanged(float delta)
11165 {
11166 SetWeightDirty();
11167 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
11168
11169 if (parent)
11170 parent.OnAttachmentQuantityChangedEx(this, delta);
11171
11172 if (IsLiquidContainer())
11173 {
11174 if (GetQuantityNormalized() <= 0.0)
11175 {
11177 }
11178 else if (GetLiquidType() == LIQUID_NONE)
11179 {
11180 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
11182 }
11183 }
11184
11185 }
11186
11189 {
11190 // insert code here
11191 }
11192
11194 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
11195 {
11197 }
11198
11199 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
11200 {
11201 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
11202
11203 if (GetGame().IsServer())
11204 {
11205 if (newLevel == GameConstants.STATE_RUINED)
11206 {
11208 EntityAI parent = GetHierarchyParent();
11209 if (parent && parent.IsFireplace())
11210 {
11211 CargoBase cargo = GetInventory().GetCargo();
11212 if (cargo)
11213 {
11214 for (int i = 0; i < cargo.GetItemCount(); ++i)
11215 {
11216 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
11217 }
11218 }
11219 }
11220 }
11221
11222 if (IsResultOfSplit())
11223 {
11224 // reset the splitting result flag, return to normal item behavior
11225 SetResultOfSplit(false);
11226 return;
11227 }
11228
11229 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
11230 {
11231 SetCleanness(0);//unclean the item upon damage dealt
11232 }
11233 }
11234 }
11235
11236 // just the split? TODO: verify
11237 override void OnRightClick()
11238 {
11239 super.OnRightClick();
11240
11241 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
11242 {
11243 if (GetGame().IsClient())
11244 {
11245 if (ScriptInputUserData.CanStoreInputUserData())
11246 {
11247 EntityAI root = GetHierarchyRoot();
11248 Man playerOwner = GetHierarchyRootPlayer();
11249 InventoryLocation dst = new InventoryLocation;
11250
11251 // 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
11252 if (!playerOwner && root && root == this)
11253 {
11255 }
11256 else
11257 {
11258 // 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
11259 GetInventory().GetCurrentInventoryLocation(dst);
11260 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
11261 {
11262 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
11263 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
11264 {
11266 }
11267 else
11268 {
11269 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
11270 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
11271 this shouldnt cause issues within this scope*/
11272 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
11273 {
11275 }
11276 else
11277 {
11278 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
11279 }
11280 }
11281 }
11282 }
11283
11284 ScriptInputUserData ctx = new ScriptInputUserData;
11286 ctx.Write(4);
11287 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11288 ctx.Write(thiz);
11289 dst.WriteToContext(ctx);
11290 ctx.Write(true); // dummy
11291 ctx.Send();
11292 }
11293 }
11294 else if (!GetGame().IsMultiplayer())
11295 {
11296 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
11297 }
11298 }
11299 }
11300
11301 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
11302 {
11303 if (root)
11304 {
11305 vector m4[4];
11306 root.GetTransform(m4);
11307 dst.SetGround(this, m4);
11308 }
11309 else
11310 {
11311 GetInventory().GetCurrentInventoryLocation(dst);
11312 }
11313 }
11314
11315 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
11316 {
11317 //TODO: delete check zero quantity check after fix double posts hands fsm events
11318 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
11319 return false;
11320
11321 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
11322 return false;
11323
11324 //can_this_be_combined = ConfigGetBool("canBeSplit");
11326 return false;
11327
11328
11329 Magazine mag = Magazine.Cast(this);
11330 if (mag)
11331 {
11332 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
11333 return false;
11334
11335 if (stack_max_limit)
11336 {
11337 Magazine other_mag = Magazine.Cast(other_item);
11338 if (other_item)
11339 {
11340 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
11341 return false;
11342 }
11343
11344 }
11345 }
11346 else
11347 {
11348 //TODO: delete check zero quantity check after fix double posts hands fsm events
11349 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
11350 return false;
11351
11352 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
11353 return false;
11354 }
11355
11356 PlayerBase player = null;
11357 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
11358 {
11359 if (player.GetInventory().HasAttachment(this))
11360 return false;
11361
11362 if (player.IsItemsToDelete())
11363 return false;
11364 }
11365
11366 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
11367 return false;
11368
11369 int slotID;
11370 string slotName;
11371 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
11372 return false;
11373
11374 return true;
11375 }
11376
11377 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
11378 {
11379 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
11380 }
11381
11382 bool IsResultOfSplit()
11383 {
11384 return m_IsResultOfSplit;
11385 }
11386
11387 void SetResultOfSplit(bool value)
11388 {
11389 m_IsResultOfSplit = value;
11390 }
11391
11392 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
11393 {
11394 return ComputeQuantityUsedEx(other_item, use_stack_max);
11395 }
11396
11397 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
11398 {
11399 float other_item_quantity = other_item.GetQuantity();
11400 float this_free_space;
11401
11402 float stack_max = GetQuantityMax();
11403
11404 this_free_space = stack_max - GetQuantity();
11405
11406 if (other_item_quantity > this_free_space)
11407 {
11408 return this_free_space;
11409 }
11410 else
11411 {
11412 return other_item_quantity;
11413 }
11414 }
11415
11416 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
11417 {
11418 CombineItems(ItemBase.Cast(entity2),use_stack_max);
11419 }
11420
11421 void CombineItems(ItemBase other_item, bool use_stack_max = true)
11422 {
11423 if (!CanBeCombined(other_item, false))
11424 return;
11425
11426 if (!IsMagazine() && other_item)
11427 {
11428 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
11429 if (quantity_used != 0)
11430 {
11431 float hp1 = GetHealth01("","");
11432 float hp2 = other_item.GetHealth01("","");
11433 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
11434 hpResult = hpResult / (GetQuantity() + quantity_used);
11435
11436 hpResult *= GetMaxHealth();
11437 Math.Round(hpResult);
11438 SetHealth("", "Health", hpResult);
11439
11440 AddQuantity(quantity_used);
11441 other_item.AddQuantity(-quantity_used);
11442 }
11443 }
11444 OnCombine(other_item);
11445 }
11446
11447 void OnCombine(ItemBase other_item)
11448 {
11449 #ifdef SERVER
11450 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11451 GetHierarchyParent().IncreaseLifetimeUp();
11452 #endif
11453 };
11454
11455 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11456 {
11457 PlayerBase p = PlayerBase.Cast(player);
11458
11459 array<int> recipesIds = p.m_Recipes;
11460 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11461 if (moduleRecipesManager)
11462 {
11463 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
11464 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11465 }
11466
11467 for (int i = 0;i < recipesIds.Count(); i++)
11468 {
11469 int key = recipesIds.Get(i);
11470 string recipeName = moduleRecipesManager.GetRecipeName(key);
11471 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11472 }
11473 }
11474
11475 // -------------------------------------------------------------------------
11476 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11477 {
11478 super.GetDebugActions(outputList);
11479
11480 //quantity
11481 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11482 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11483 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11484 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11485 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11486
11487 //health
11488 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
11489 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
11490 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
11491 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11492 //temperature
11493 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
11494 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
11495 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
11496 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11497
11498 //wet
11499 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
11500 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
11501 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11502
11503 //liquidtype
11504 if (IsLiquidContainer())
11505 {
11506 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
11507 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
11508 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11509 }
11510
11511 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
11512 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11513
11514 // watch
11515 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
11516 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
11517 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11518
11519 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
11520
11521 InventoryLocation loc = new InventoryLocation();
11522 GetInventory().GetCurrentInventoryLocation(loc);
11523 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11524 {
11525 if (Gizmo_IsSupported())
11526 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11527 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11528 }
11529
11530 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11531 }
11532
11533 // -------------------------------------------------------------------------
11534 // -------------------------------------------------------------------------
11535 // -------------------------------------------------------------------------
11536 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11537 {
11538 super.OnAction(action_id, player, ctx);
11539
11540 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
11541 {
11542 switch (action_id)
11543 {
11544 case EActions.GIZMO_OBJECT:
11545 GetGame().GizmoSelectObject(this);
11546 return true;
11547 case EActions.GIZMO_PHYSICS:
11548 GetGame().GizmoSelectPhysics(GetPhysics());
11549 return true;
11550 }
11551 }
11552
11553 if (GetGame().IsServer())
11554 {
11555 switch (action_id)
11556 {
11557 case EActions.DELETE:
11558 Delete();
11559 return true;
11560 }
11561 }
11562
11563 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11564 {
11565 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11566 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11567 PlayerBase p = PlayerBase.Cast(player);
11568 if (EActions.RECIPES_RANGE_START < 1000)
11569 {
11570 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11571 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11572 }
11573 }
11574 #ifndef SERVER
11575 else if (action_id == EActions.WATCH_PLAYER)
11576 {
11577 PluginDeveloper.SetDeveloperItemClientEx(player);
11578 }
11579 #endif
11580 if (GetGame().IsServer())
11581 {
11582 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11583 {
11584 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11585 OnDebugButtonPressServer(id + 1);
11586 }
11587
11588 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11589 {
11590 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11591 InsertAgent(agent_id,100);
11592 }
11593
11594 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11595 {
11596 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11597 RemoveAgent(agent_id2);
11598 }
11599
11600 else if (action_id == EActions.ADD_QUANTITY)
11601 {
11602 if (IsMagazine())
11603 {
11604 Magazine mag = Magazine.Cast(this);
11605 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11606 }
11607 else
11608 {
11609 AddQuantity(GetQuantityMax() * 0.2);
11610 }
11611
11612 if (m_EM)
11613 {
11614 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11615 }
11616 //PrintVariables();
11617 }
11618
11619 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11620 {
11621 if (IsMagazine())
11622 {
11623 Magazine mag2 = Magazine.Cast(this);
11624 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11625 }
11626 else
11627 {
11628 AddQuantity(- GetQuantityMax() * 0.2);
11629 }
11630 if (m_EM)
11631 {
11632 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11633 }
11634 //PrintVariables();
11635 }
11636
11637 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11638 {
11639 SetQuantity(0);
11640
11641 if (m_EM)
11642 {
11643 m_EM.SetEnergy(0);
11644 }
11645 }
11646
11647 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11648 {
11650
11651 if (m_EM)
11652 {
11653 m_EM.SetEnergy(m_EM.GetEnergyMax());
11654 }
11655 }
11656
11657 else if (action_id == EActions.ADD_HEALTH)
11658 {
11659 AddHealth("","",GetMaxHealth("","Health")/5);
11660 }
11661 else if (action_id == EActions.REMOVE_HEALTH)
11662 {
11663 AddHealth("","",-GetMaxHealth("","Health")/5);
11664 }
11665 else if (action_id == EActions.DESTROY_HEALTH)
11666 {
11667 SetHealth01("","",0);
11668 }
11669 else if (action_id == EActions.WATCH_ITEM)
11670 {
11672 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11673 #ifdef DEVELOPER
11674 SetDebugDeveloper_item(this);
11675 #endif
11676 }
11677
11678 else if (action_id == EActions.ADD_TEMPERATURE)
11679 {
11680 AddTemperature(20);
11681 //PrintVariables();
11682 }
11683
11684 else if (action_id == EActions.REMOVE_TEMPERATURE)
11685 {
11686 AddTemperature(-20);
11687 //PrintVariables();
11688 }
11689
11690 else if (action_id == EActions.FLIP_FROZEN)
11691 {
11692 SetFrozen(!GetIsFrozen());
11693 //PrintVariables();
11694 }
11695
11696 else if (action_id == EActions.ADD_WETNESS)
11697 {
11698 AddWet(GetWetMax()/5);
11699 //PrintVariables();
11700 }
11701
11702 else if (action_id == EActions.REMOVE_WETNESS)
11703 {
11704 AddWet(-GetWetMax()/5);
11705 //PrintVariables();
11706 }
11707
11708 else if (action_id == EActions.LIQUIDTYPE_UP)
11709 {
11710 int curr_type = GetLiquidType();
11711 SetLiquidType(curr_type * 2);
11712 //AddWet(1);
11713 //PrintVariables();
11714 }
11715
11716 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11717 {
11718 int curr_type2 = GetLiquidType();
11719 SetLiquidType(curr_type2 / 2);
11720 }
11721
11722 else if (action_id == EActions.MAKE_SPECIAL)
11723 {
11724 auto debugParams = DebugSpawnParams.WithPlayer(player);
11725 OnDebugSpawnEx(debugParams);
11726 }
11727
11728 }
11729
11730
11731 return false;
11732 }
11733
11734 // -------------------------------------------------------------------------
11735
11736
11739 void OnActivatedByTripWire();
11740
11742 void OnActivatedByItem(notnull ItemBase item);
11743
11744 //----------------------------------------------------------------
11745 //returns true if item is able to explode when put in fire
11746 bool CanExplodeInFire()
11747 {
11748 return false;
11749 }
11750
11751 //----------------------------------------------------------------
11752 bool CanEat()
11753 {
11754 return true;
11755 }
11756
11757 //----------------------------------------------------------------
11758 override bool IsIgnoredByConstruction()
11759 {
11760 return true;
11761 }
11762
11763 //----------------------------------------------------------------
11764 //has FoodStages in config?
11765 bool HasFoodStage()
11766 {
11767 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11768 return GetGame().ConfigIsExisting(config_path);
11769 }
11770
11772 FoodStage GetFoodStage()
11773 {
11774 return null;
11775 }
11776
11777 bool CanBeCooked()
11778 {
11779 return false;
11780 }
11781
11782 bool CanBeCookedOnStick()
11783 {
11784 return false;
11785 }
11786
11788 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11790
11791 //----------------------------------------------------------------
11792 bool CanRepair(ItemBase item_repair_kit)
11793 {
11794 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11795 return module_repairing.CanRepair(this, item_repair_kit);
11796 }
11797
11798 //----------------------------------------------------------------
11799 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11800 {
11801 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11802 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11803 }
11804
11805 //----------------------------------------------------------------
11806 int GetItemSize()
11807 {
11808 /*
11809 vector v_size = this.ConfigGetVector("itemSize");
11810 int v_size_x = v_size[0];
11811 int v_size_y = v_size[1];
11812 int size = v_size_x * v_size_y;
11813 return size;
11814 */
11815
11816 return 1;
11817 }
11818
11819 //----------------------------------------------------------------
11820 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11821 bool CanBeMovedOverride()
11822 {
11823 return m_CanBeMovedOverride;
11824 }
11825
11826 //----------------------------------------------------------------
11827 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11828 void SetCanBeMovedOverride(bool setting)
11829 {
11830 m_CanBeMovedOverride = setting;
11831 }
11832
11833 //----------------------------------------------------------------
11841 void MessageToOwnerStatus(string text)
11842 {
11843 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11844
11845 if (player)
11846 {
11847 player.MessageStatus(text);
11848 }
11849 }
11850
11851 //----------------------------------------------------------------
11859 void MessageToOwnerAction(string text)
11860 {
11861 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11862
11863 if (player)
11864 {
11865 player.MessageAction(text);
11866 }
11867 }
11868
11869 //----------------------------------------------------------------
11877 void MessageToOwnerFriendly(string text)
11878 {
11879 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11880
11881 if (player)
11882 {
11883 player.MessageFriendly(text);
11884 }
11885 }
11886
11887 //----------------------------------------------------------------
11895 void MessageToOwnerImportant(string text)
11896 {
11897 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11898
11899 if (player)
11900 {
11901 player.MessageImportant(text);
11902 }
11903 }
11904
11905 override bool IsItemBase()
11906 {
11907 return true;
11908 }
11909
11910 // Checks if item is of questioned kind
11911 override bool KindOf(string tag)
11912 {
11913 bool found = false;
11914 string item_name = this.GetType();
11915 ref TStringArray item_tag_array = new TStringArray;
11916 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11917
11918 int array_size = item_tag_array.Count();
11919 for (int i = 0; i < array_size; i++)
11920 {
11921 if (item_tag_array.Get(i) == tag)
11922 {
11923 found = true;
11924 break;
11925 }
11926 }
11927 return found;
11928 }
11929
11930
11931 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11932 {
11933 //Debug.Log("OnRPC called");
11934 super.OnRPC(sender, rpc_type,ctx);
11935
11936 //Play soundset for attachment locking (ActionLockAttachment.c)
11937 switch (rpc_type)
11938 {
11939 #ifndef SERVER
11940 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11941 Param2<bool, string> p = new Param2<bool, string>(false, "");
11942
11943 if (!ctx.Read(p))
11944 return;
11945
11946 bool play = p.param1;
11947 string soundSet = p.param2;
11948
11949 if (play)
11950 {
11951 if (m_LockingSound)
11952 {
11954 {
11955 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11956 }
11957 }
11958 else
11959 {
11960 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11961 }
11962 }
11963 else
11964 {
11965 SEffectManager.DestroyEffect(m_LockingSound);
11966 }
11967
11968 break;
11969 #endif
11970
11971 }
11972
11973 if (GetWrittenNoteData())
11974 {
11975 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11976 }
11977 }
11978
11979 //-----------------------------
11980 // VARIABLE MANIPULATION SYSTEM
11981 //-----------------------------
11982 int NameToID(string name)
11983 {
11984 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11985 return plugin.GetID(name);
11986 }
11987
11988 string IDToName(int id)
11989 {
11990 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11991 return plugin.GetName(id);
11992 }
11993
11995 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11996 {
11997 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11998 //read the flags
11999 int varFlags;
12000 if (!ctx.Read(varFlags))
12001 return;
12002
12003 if (varFlags & ItemVariableFlags.FLOAT)
12004 {
12005 ReadVarsFromCTX(ctx);
12006 }
12007 }
12008
12009 override void SerializeNumericalVars(array<float> floats_out)
12010 {
12011 //some variables handled on EntityAI level already!
12012 super.SerializeNumericalVars(floats_out);
12013
12014 // the order of serialization must be the same as the order of de-serialization
12015 //--------------------------------------------
12016 if (IsVariableSet(VARIABLE_QUANTITY))
12017 {
12018 floats_out.Insert(m_VarQuantity);
12019 }
12020 //--------------------------------------------
12021 if (IsVariableSet(VARIABLE_WET))
12022 {
12023 floats_out.Insert(m_VarWet);
12024 }
12025 //--------------------------------------------
12026 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
12027 {
12028 floats_out.Insert(m_VarLiquidType);
12029 }
12030 //--------------------------------------------
12031 if (IsVariableSet(VARIABLE_COLOR))
12032 {
12033 floats_out.Insert(m_ColorComponentR);
12034 floats_out.Insert(m_ColorComponentG);
12035 floats_out.Insert(m_ColorComponentB);
12036 floats_out.Insert(m_ColorComponentA);
12037 }
12038 //--------------------------------------------
12039 if (IsVariableSet(VARIABLE_CLEANNESS))
12040 {
12041 floats_out.Insert(m_Cleanness);
12042 }
12043 }
12044
12045 override void DeSerializeNumericalVars(array<float> floats)
12046 {
12047 //some variables handled on EntityAI level already!
12048 super.DeSerializeNumericalVars(floats);
12049
12050 // the order of serialization must be the same as the order of de-serialization
12051 int index = 0;
12052 int mask = Math.Round(floats.Get(index));
12053
12054 index++;
12055 //--------------------------------------------
12056 if (mask & VARIABLE_QUANTITY)
12057 {
12058 if (m_IsStoreLoad)
12059 {
12060 SetStoreLoadedQuantity(floats.Get(index));
12061 }
12062 else
12063 {
12064 float quantity = floats.Get(index);
12065 SetQuantity(quantity, true, false, false, false);
12066 }
12067 index++;
12068 }
12069 //--------------------------------------------
12070 if (mask & VARIABLE_WET)
12071 {
12072 float wet = floats.Get(index);
12073 SetWet(wet);
12074 index++;
12075 }
12076 //--------------------------------------------
12077 if (mask & VARIABLE_LIQUIDTYPE)
12078 {
12079 int liquidtype = Math.Round(floats.Get(index));
12080 SetLiquidType(liquidtype);
12081 index++;
12082 }
12083 //--------------------------------------------
12084 if (mask & VARIABLE_COLOR)
12085 {
12086 m_ColorComponentR = Math.Round(floats.Get(index));
12087 index++;
12088 m_ColorComponentG = Math.Round(floats.Get(index));
12089 index++;
12090 m_ColorComponentB = Math.Round(floats.Get(index));
12091 index++;
12092 m_ColorComponentA = Math.Round(floats.Get(index));
12093 index++;
12094 }
12095 //--------------------------------------------
12096 if (mask & VARIABLE_CLEANNESS)
12097 {
12098 int cleanness = Math.Round(floats.Get(index));
12099 SetCleanness(cleanness);
12100 index++;
12101 }
12102 }
12103
12104 override void WriteVarsToCTX(ParamsWriteContext ctx)
12105 {
12106 super.WriteVarsToCTX(ctx);
12107
12108 //--------------------------------------------
12109 if (IsVariableSet(VARIABLE_QUANTITY))
12110 {
12111 ctx.Write(GetQuantity());
12112 }
12113 //--------------------------------------------
12114 if (IsVariableSet(VARIABLE_WET))
12115 {
12116 ctx.Write(GetWet());
12117 }
12118 //--------------------------------------------
12119 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
12120 {
12121 ctx.Write(GetLiquidType());
12122 }
12123 //--------------------------------------------
12124 if (IsVariableSet(VARIABLE_COLOR))
12125 {
12126 int r,g,b,a;
12127 GetColor(r,g,b,a);
12128 ctx.Write(r);
12129 ctx.Write(g);
12130 ctx.Write(b);
12131 ctx.Write(a);
12132 }
12133 //--------------------------------------------
12134 if (IsVariableSet(VARIABLE_CLEANNESS))
12135 {
12136 ctx.Write(GetCleanness());
12137 }
12138 }
12139
12140 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
12141 {
12142 if (!super.ReadVarsFromCTX(ctx,version))
12143 return false;
12144
12145 int intValue;
12146 float value;
12147
12148 if (version < 140)
12149 {
12150 if (!ctx.Read(intValue))
12151 return false;
12152
12153 m_VariablesMask = intValue;
12154 }
12155
12156 if (m_VariablesMask & VARIABLE_QUANTITY)
12157 {
12158 if (!ctx.Read(value))
12159 return false;
12160
12161 if (IsStoreLoad())
12162 {
12164 }
12165 else
12166 {
12167 SetQuantity(value, true, false, false, false);
12168 }
12169 }
12170 //--------------------------------------------
12171 if (version < 140)
12172 {
12173 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12174 {
12175 if (!ctx.Read(value))
12176 return false;
12177 SetTemperatureDirect(value);
12178 }
12179 }
12180 //--------------------------------------------
12181 if (m_VariablesMask & VARIABLE_WET)
12182 {
12183 if (!ctx.Read(value))
12184 return false;
12185 SetWet(value);
12186 }
12187 //--------------------------------------------
12188 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
12189 {
12190 if (!ctx.Read(intValue))
12191 return false;
12192 SetLiquidType(intValue);
12193 }
12194 //--------------------------------------------
12195 if (m_VariablesMask & VARIABLE_COLOR)
12196 {
12197 int r,g,b,a;
12198 if (!ctx.Read(r))
12199 return false;
12200 if (!ctx.Read(g))
12201 return false;
12202 if (!ctx.Read(b))
12203 return false;
12204 if (!ctx.Read(a))
12205 return false;
12206
12207 SetColor(r,g,b,a);
12208 }
12209 //--------------------------------------------
12210 if (m_VariablesMask & VARIABLE_CLEANNESS)
12211 {
12212 if (!ctx.Read(intValue))
12213 return false;
12214 SetCleanness(intValue);
12215 }
12216 //--------------------------------------------
12217 if (version >= 138 && version < 140)
12218 {
12219 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12220 {
12221 if (!ctx.Read(intValue))
12222 return false;
12223 SetFrozen(intValue);
12224 }
12225 }
12226
12227 return true;
12228 }
12229
12230 //----------------------------------------------------------------
12231 override bool OnStoreLoad(ParamsReadContext ctx, int version)
12232 {
12233 m_IsStoreLoad = true;
12235 {
12236 m_FixDamageSystemInit = true;
12237 }
12238
12239 if (!super.OnStoreLoad(ctx, version))
12240 {
12241 m_IsStoreLoad = false;
12242 return false;
12243 }
12244
12245 if (version >= 114)
12246 {
12247 bool hasQuickBarIndexSaved;
12248
12249 if (!ctx.Read(hasQuickBarIndexSaved))
12250 {
12251 m_IsStoreLoad = false;
12252 return false;
12253 }
12254
12255 if (hasQuickBarIndexSaved)
12256 {
12257 int itmQBIndex;
12258
12259 //Load quickbar item bind
12260 if (!ctx.Read(itmQBIndex))
12261 {
12262 m_IsStoreLoad = false;
12263 return false;
12264 }
12265
12266 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
12267 if (itmQBIndex != -1 && parentPlayer)
12268 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
12269 }
12270 }
12271 else
12272 {
12273 // Backup of how it used to be
12274 PlayerBase player;
12275 int itemQBIndex;
12276 if (version == int.MAX)
12277 {
12278 if (!ctx.Read(itemQBIndex))
12279 {
12280 m_IsStoreLoad = false;
12281 return false;
12282 }
12283 }
12284 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
12285 {
12286 //Load quickbar item bind
12287 if (!ctx.Read(itemQBIndex))
12288 {
12289 m_IsStoreLoad = false;
12290 return false;
12291 }
12292 if (itemQBIndex != -1 && player)
12293 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
12294 }
12295 }
12296
12297 if (version < 140)
12298 {
12299 // variable management system
12300 if (!LoadVariables(ctx, version))
12301 {
12302 m_IsStoreLoad = false;
12303 return false;
12304 }
12305 }
12306
12307 //agent trasmission system
12308 if (!LoadAgents(ctx, version))
12309 {
12310 m_IsStoreLoad = false;
12311 return false;
12312 }
12313 if (version >= 132)
12314 {
12315 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12316 if (raib)
12317 {
12318 if (!raib.OnStoreLoad(ctx,version))
12319 {
12320 m_IsStoreLoad = false;
12321 return false;
12322 }
12323 }
12324 }
12325
12326 m_IsStoreLoad = false;
12327 return true;
12328 }
12329
12330 //----------------------------------------------------------------
12331
12332 override void OnStoreSave(ParamsWriteContext ctx)
12333 {
12334 super.OnStoreSave(ctx);
12335
12336 PlayerBase player;
12337 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
12338 {
12339 ctx.Write(true); // Keep track of if we should actually read this in or not
12340 //Save quickbar item bind
12341 int itemQBIndex = -1;
12342 itemQBIndex = player.FindQuickBarEntityIndex(this);
12343 ctx.Write(itemQBIndex);
12344 }
12345 else
12346 {
12347 ctx.Write(false); // Keep track of if we should actually read this in or not
12348 }
12349
12350 SaveAgents(ctx);//agent trasmission system
12351
12352 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12353 if (raib)
12354 {
12355 raib.OnStoreSave(ctx);
12356 }
12357 }
12358 //----------------------------------------------------------------
12359
12360 override void AfterStoreLoad()
12361 {
12362 super.AfterStoreLoad();
12363
12365 {
12367 }
12368
12369 if (GetStoreLoadedQuantity() != float.LOWEST)
12370 {
12372 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
12373 }
12374 }
12375
12376 override void EEOnAfterLoad()
12377 {
12378 super.EEOnAfterLoad();
12379
12381 {
12382 m_FixDamageSystemInit = false;
12383 }
12384
12387 }
12388
12389 bool CanBeDisinfected()
12390 {
12391 return false;
12392 }
12393
12394
12395 //----------------------------------------------------------------
12396 override void OnVariablesSynchronized()
12397 {
12398 if (m_Initialized)
12399 {
12400 #ifdef PLATFORM_CONSOLE
12401 //bruteforce it is
12402 if (IsSplitable())
12403 {
12404 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
12405 if (menu)
12406 {
12407 menu.Refresh();
12408 }
12409 }
12410 #endif
12411 }
12412
12414 {
12415 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
12416 m_WantPlayImpactSound = false;
12417 }
12418
12420 {
12421 SetWeightDirty();
12423 }
12424 if (m_VarWet != m_VarWetPrev)
12425 {
12428 }
12429
12430 if (m_SoundSyncPlay != 0)
12431 {
12432 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
12433 m_SoundSyncPlay = 0;
12434 }
12435 if (m_SoundSyncStop != 0)
12436 {
12437 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12438 m_SoundSyncStop = 0;
12439 }
12440
12441 super.OnVariablesSynchronized();
12442 }
12443
12444 //------------------------- Quantity
12445 //----------------------------------------------------------------
12447 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12448 {
12449 if (!IsServerCheck(allow_client))
12450 return false;
12451
12452 if (!HasQuantity())
12453 return false;
12454
12455 float min = GetQuantityMin();
12456 float max = GetQuantityMax();
12457
12458 if (value <= (min + 0.001))
12459 value = min;
12460
12461 if (value == min)
12462 {
12463 if (destroy_config)
12464 {
12465 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12466 if (dstr)
12467 {
12468 m_VarQuantity = Math.Clamp(value, min, max);
12469 this.Delete();
12470 return true;
12471 }
12472 }
12473 else if (destroy_forced)
12474 {
12475 m_VarQuantity = Math.Clamp(value, min, max);
12476 this.Delete();
12477 return true;
12478 }
12479 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12480 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12481 }
12482
12483 float delta = m_VarQuantity;
12484 m_VarQuantity = Math.Clamp(value, min, max);
12485
12486 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
12487 {
12488 delta = m_VarQuantity - delta;
12489
12490 if (delta)
12491 OnQuantityChanged(delta);
12492 }
12493
12494 SetVariableMask(VARIABLE_QUANTITY);
12495
12496 return false;
12497 }
12498
12499 //----------------------------------------------------------------
12501 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
12502 {
12503 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
12504 }
12505 //----------------------------------------------------------------
12506 void SetQuantityMax()
12507 {
12508 float max = GetQuantityMax();
12509 SetQuantity(max);
12510 }
12511
12512 override void SetQuantityToMinimum()
12513 {
12514 float min = GetQuantityMin();
12515 SetQuantity(min);
12516 }
12517 //----------------------------------------------------------------
12519 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
12520 {
12521 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
12522 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
12523 SetQuantity(result, destroy_config, destroy_forced);
12524 }
12525
12526 //----------------------------------------------------------------
12528 override float GetQuantityNormalized()
12529 {
12530 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12531 }
12532
12534 {
12535 return GetQuantityNormalized();
12536 }
12537
12538 /*void SetAmmoNormalized(float value)
12539 {
12540 float value_clamped = Math.Clamp(value, 0, 1);
12541 Magazine this_mag = Magazine.Cast(this);
12542 int max_rounds = this_mag.GetAmmoMax();
12543 int result = value * max_rounds;//can the rounded if higher precision is required
12544 this_mag.SetAmmoCount(result);
12545 }*/
12546 //----------------------------------------------------------------
12547 override int GetQuantityMax()
12548 {
12549 int slot = -1;
12550 if (GetInventory())
12551 {
12552 InventoryLocation il = new InventoryLocation;
12553 GetInventory().GetCurrentInventoryLocation(il);
12554 slot = il.GetSlot();
12555 }
12556
12557 return GetTargetQuantityMax(slot);
12558 }
12559
12560 override int GetTargetQuantityMax(int attSlotID = -1)
12561 {
12562 float quantity_max = 0;
12563
12564 if (IsSplitable()) //only stackable/splitable items can check for stack size
12565 {
12566 if (attSlotID != -1)
12567 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12568
12569 if (quantity_max <= 0)
12570 quantity_max = m_VarStackMax;
12571 }
12572
12573 if (quantity_max <= 0)
12574 quantity_max = m_VarQuantityMax;
12575
12576 return quantity_max;
12577 }
12578 //----------------------------------------------------------------
12579 override int GetQuantityMin()
12580 {
12581 return m_VarQuantityMin;
12582 }
12583 //----------------------------------------------------------------
12584 int GetQuantityInit()
12585 {
12586 return m_VarQuantityInit;
12587 }
12588
12589 //----------------------------------------------------------------
12590 override bool HasQuantity()
12591 {
12592 return !(GetQuantityMax() - GetQuantityMin() == 0);
12593 }
12594
12595 override float GetQuantity()
12596 {
12597 return m_VarQuantity;
12598 }
12599
12600 bool IsFullQuantity()
12601 {
12602 return GetQuantity() >= GetQuantityMax();
12603 }
12604
12605 //Calculates weight of single item without attachments and cargo
12606 override float GetSingleInventoryItemWeightEx()
12607 {
12608 //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
12609 float weightEx = GetWeightEx();//overall weight of the item
12610 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12611 return weightEx - special;
12612 }
12613
12614 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12616 {
12618 }
12619
12620 override protected float GetWeightSpecialized(bool forceRecalc = false)
12621 {
12622 if (IsSplitable()) //quantity determines size of the stack
12623 {
12624 #ifdef DEVELOPER
12625 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12626 {
12627 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12628 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12629 }
12630 #endif
12631
12632 return GetQuantity() * GetConfigWeightModified();
12633 }
12634 else if (HasEnergyManager())// items with energy manager
12635 {
12636 #ifdef DEVELOPER
12637 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12638 {
12639 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12640 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12641 }
12642 #endif
12643 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12644 }
12645 else//everything else
12646 {
12647 #ifdef DEVELOPER
12648 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12649 {
12650 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12651 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12652 }
12653 #endif
12654 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12655 }
12656 }
12657
12659 int GetNumberOfItems()
12660 {
12661 int item_count = 0;
12662 ItemBase item;
12663
12664 if (GetInventory().GetCargo() != NULL)
12665 {
12666 item_count = GetInventory().GetCargo().GetItemCount();
12667 }
12668
12669 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
12670 {
12671 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
12672 if (item)
12673 item_count += item.GetNumberOfItems();
12674 }
12675 return item_count;
12676 }
12677
12679 float GetUnitWeight(bool include_wetness = true)
12680 {
12681 float weight = 0;
12682 float wetness = 1;
12683 if (include_wetness)
12684 wetness += GetWet();
12685 if (IsSplitable()) //quantity determines size of the stack
12686 {
12687 weight = wetness * m_ConfigWeight;
12688 }
12689 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12690 {
12691 weight = 1;
12692 }
12693 return weight;
12694 }
12695
12696 //-----------------------------------------------------------------
12697
12698 override void ClearInventory()
12699 {
12700 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
12701 {
12702 GameInventory inv = GetInventory();
12703 array<EntityAI> items = new array<EntityAI>;
12704 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
12705 for (int i = 0; i < items.Count(); i++)
12706 {
12707 ItemBase item = ItemBase.Cast(items.Get(i));
12708 if (item)
12709 {
12710 GetGame().ObjectDelete(item);
12711 }
12712 }
12713 }
12714 }
12715
12716 //------------------------- Energy
12717
12718 //----------------------------------------------------------------
12719 float GetEnergy()
12720 {
12721 float energy = 0;
12722 if (HasEnergyManager())
12723 {
12724 energy = GetCompEM().GetEnergy();
12725 }
12726 return energy;
12727 }
12728
12729
12730 override void OnEnergyConsumed()
12731 {
12732 super.OnEnergyConsumed();
12733
12735 }
12736
12737 override void OnEnergyAdded()
12738 {
12739 super.OnEnergyAdded();
12740
12742 }
12743
12744 // Converts energy (from Energy Manager) to quantity, if enabled.
12746 {
12747 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12748 {
12749 if (HasQuantity())
12750 {
12751 float energy_0to1 = GetCompEM().GetEnergy0To1();
12752 SetQuantityNormalized(energy_0to1);
12753 }
12754 }
12755 }
12756
12757 //----------------------------------------------------------------
12758 float GetHeatIsolationInit()
12759 {
12760 return ConfigGetFloat("heatIsolation");
12761 }
12762
12763 float GetHeatIsolation()
12764 {
12765 return m_HeatIsolation;
12766 }
12767
12768 float GetDryingIncrement(string pIncrementName)
12769 {
12770 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12771 if (GetGame().ConfigIsExisting(paramPath))
12772 return GetGame().ConfigGetFloat(paramPath);
12773
12774 return 0.0;
12775 }
12776
12777 float GetSoakingIncrement(string pIncrementName)
12778 {
12779 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12780 if (GetGame().ConfigIsExisting(paramPath))
12781 return GetGame().ConfigGetFloat(paramPath);
12782
12783 return 0.0;
12784 }
12785 //----------------------------------------------------------------
12786 override void SetWet(float value, bool allow_client = false)
12787 {
12788 if (!IsServerCheck(allow_client))
12789 return;
12790
12791 float min = GetWetMin();
12792 float max = GetWetMax();
12793
12794 float previousValue = m_VarWet;
12795
12796 m_VarWet = Math.Clamp(value, min, max);
12797
12798 if (previousValue != m_VarWet)
12799 {
12800 SetVariableMask(VARIABLE_WET);
12801 OnWetChanged(m_VarWet, previousValue);
12802 }
12803 }
12804 //----------------------------------------------------------------
12805 override void AddWet(float value)
12806 {
12807 SetWet(GetWet() + value);
12808 }
12809 //----------------------------------------------------------------
12810 override void SetWetMax()
12811 {
12813 }
12814 //----------------------------------------------------------------
12815 override float GetWet()
12816 {
12817 return m_VarWet;
12818 }
12819 //----------------------------------------------------------------
12820 override float GetWetMax()
12821 {
12822 return m_VarWetMax;
12823 }
12824 //----------------------------------------------------------------
12825 override float GetWetMin()
12826 {
12827 return m_VarWetMin;
12828 }
12829 //----------------------------------------------------------------
12830 override float GetWetInit()
12831 {
12832 return m_VarWetInit;
12833 }
12834 //----------------------------------------------------------------
12835 override void OnWetChanged(float newVal, float oldVal)
12836 {
12837 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12838 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12839 if (newLevel != oldLevel)
12840 {
12841 OnWetLevelChanged(newLevel,oldLevel);
12842 }
12843 }
12844
12845 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12846 {
12847 SetWeightDirty();
12848 }
12849
12850 override EWetnessLevel GetWetLevel()
12851 {
12852 return GetWetLevelInternal(m_VarWet);
12853 }
12854
12855 //----------------------------------------------------------------
12856
12857 override void SetStoreLoad(bool value)
12858 {
12859 m_IsStoreLoad = value;
12860 }
12861
12862 override bool IsStoreLoad()
12863 {
12864 return m_IsStoreLoad;
12865 }
12866
12867 override void SetStoreLoadedQuantity(float value)
12868 {
12869 m_StoreLoadedQuantity = value;
12870 }
12871
12872 override float GetStoreLoadedQuantity()
12873 {
12874 return m_StoreLoadedQuantity;
12875 }
12876
12877 //----------------------------------------------------------------
12878
12879 float GetItemModelLength()
12880 {
12881 if (ConfigIsExisting("itemModelLength"))
12882 {
12883 return ConfigGetFloat("itemModelLength");
12884 }
12885 return 0;
12886 }
12887
12888 float GetItemAttachOffset()
12889 {
12890 if (ConfigIsExisting("itemAttachOffset"))
12891 {
12892 return ConfigGetFloat("itemAttachOffset");
12893 }
12894 return 0;
12895 }
12896
12897 override void SetCleanness(int value, bool allow_client = false)
12898 {
12899 if (!IsServerCheck(allow_client))
12900 return;
12901
12902 int previousValue = m_Cleanness;
12903
12904 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12905
12906 if (previousValue != m_Cleanness)
12907 SetVariableMask(VARIABLE_CLEANNESS);
12908 }
12909
12910 override int GetCleanness()
12911 {
12912 return m_Cleanness;
12913 }
12914
12916 {
12917 return true;
12918 }
12919
12920 //----------------------------------------------------------------
12921 // ATTACHMENT LOCKING
12922 // Getters relevant to generic ActionLockAttachment
12923 int GetLockType()
12924 {
12925 return m_LockType;
12926 }
12927
12928 string GetLockSoundSet()
12929 {
12930 return m_LockSoundSet;
12931 }
12932
12933 //----------------------------------------------------------------
12934 //------------------------- Color
12935 // sets items color variable given color components
12936 override void SetColor(int r, int g, int b, int a)
12937 {
12942 SetVariableMask(VARIABLE_COLOR);
12943 }
12945 override void GetColor(out int r,out int g,out int b,out int a)
12946 {
12951 }
12952
12953 bool IsColorSet()
12954 {
12955 return IsVariableSet(VARIABLE_COLOR);
12956 }
12957
12959 string GetColorString()
12960 {
12961 int r,g,b,a;
12962 GetColor(r,g,b,a);
12963 r = r/255;
12964 g = g/255;
12965 b = b/255;
12966 a = a/255;
12967 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12968 }
12969 //----------------------------------------------------------------
12970 //------------------------- LiquidType
12971
12972 override void SetLiquidType(int value, bool allow_client = false)
12973 {
12974 if (!IsServerCheck(allow_client))
12975 return;
12976
12977 int old = m_VarLiquidType;
12978 m_VarLiquidType = value;
12979 OnLiquidTypeChanged(old,value);
12980 SetVariableMask(VARIABLE_LIQUIDTYPE);
12981 }
12982
12983 int GetLiquidTypeInit()
12984 {
12985 return ConfigGetInt("varLiquidTypeInit");
12986 }
12987
12988 override int GetLiquidType()
12989 {
12990 return m_VarLiquidType;
12991 }
12992
12993 protected void OnLiquidTypeChanged(int oldType, int newType)
12994 {
12995 if (newType == LIQUID_NONE && GetIsFrozen())
12996 SetFrozen(false);
12997 }
12998
13000 void UpdateQuickbarShortcutVisibility(PlayerBase player)
13001 {
13002 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
13003 }
13004
13005 // -------------------------------------------------------------------------
13007 void OnInventoryEnter(Man player)
13008 {
13009 PlayerBase nplayer;
13010 if (PlayerBase.CastTo(nplayer, player))
13011 {
13012 m_CanPlayImpactSound = true;
13013 //nplayer.OnItemInventoryEnter(this);
13014 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
13015 }
13016 }
13017
13018 // -------------------------------------------------------------------------
13020 void OnInventoryExit(Man player)
13021 {
13022 PlayerBase nplayer;
13023 if (PlayerBase.CastTo(nplayer,player))
13024 {
13025 //nplayer.OnItemInventoryExit(this);
13026 nplayer.SetEnableQuickBarEntityShortcut(this,false);
13027
13028 }
13029
13030 //if (!GetGame().IsDedicatedServer())
13031 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
13032
13033
13034 if (HasEnergyManager())
13035 {
13036 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
13037 }
13038 }
13039
13040 // ADVANCED PLACEMENT EVENTS
13041 override void OnPlacementStarted(Man player)
13042 {
13043 super.OnPlacementStarted(player);
13044
13045 SetTakeable(false);
13046 }
13047
13048 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
13049 {
13050 if (m_AdminLog)
13051 {
13052 m_AdminLog.OnPlacementComplete(player, this);
13053 }
13054
13055 super.OnPlacementComplete(player, position, orientation);
13056 }
13057
13058 //-----------------------------
13059 // AGENT SYSTEM
13060 //-----------------------------
13061 //--------------------------------------------------------------------------
13062 bool ContainsAgent(int agent_id)
13063 {
13064 if (agent_id & m_AttachedAgents)
13065 {
13066 return true;
13067 }
13068 else
13069 {
13070 return false;
13071 }
13072 }
13073
13074 //--------------------------------------------------------------------------
13075 override void RemoveAgent(int agent_id)
13076 {
13077 if (ContainsAgent(agent_id))
13078 {
13079 m_AttachedAgents = ~agent_id & m_AttachedAgents;
13080 }
13081 }
13082
13083 //--------------------------------------------------------------------------
13084 override void RemoveAllAgents()
13085 {
13086 m_AttachedAgents = 0;
13087 }
13088 //--------------------------------------------------------------------------
13089 override void RemoveAllAgentsExcept(int agent_to_keep)
13090 {
13091 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
13092 }
13093 // -------------------------------------------------------------------------
13094 override void InsertAgent(int agent, float count = 1)
13095 {
13096 if (count < 1)
13097 return;
13098 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
13100 }
13101
13103 void TransferAgents(int agents)
13104 {
13106 }
13107
13108 // -------------------------------------------------------------------------
13109 override int GetAgents()
13110 {
13111 return m_AttachedAgents;
13112 }
13113 //----------------------------------------------------------------------
13114
13115 /*int GetContaminationType()
13116 {
13117 int contamination_type;
13118
13119 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
13120 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
13121 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
13122 const int DIRTY_MASK = eAgents.WOUND_AGENT;
13123
13124 Edible_Base edible = Edible_Base.Cast(this);
13125 int agents = GetAgents();
13126 if (edible)
13127 {
13128 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
13129 if (profile)
13130 {
13131 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
13132 }
13133 }
13134 if (agents & CONTAMINATED_MASK)
13135 {
13136 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
13137 }
13138 if (agents & POISONED_MASK)
13139 {
13140 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
13141 }
13142 if (agents & NERVE_GAS_MASK)
13143 {
13144 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
13145 }
13146 if (agents & DIRTY_MASK)
13147 {
13148 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
13149 }
13150
13151 return agents;
13152 }*/
13153
13154 // -------------------------------------------------------------------------
13155 bool LoadAgents(ParamsReadContext ctx, int version)
13156 {
13157 if (!ctx.Read(m_AttachedAgents))
13158 return false;
13159 return true;
13160 }
13161 // -------------------------------------------------------------------------
13163 {
13164
13166 }
13167 // -------------------------------------------------------------------------
13168
13170 override void CheckForRoofLimited(float timeTresholdMS = 3000)
13171 {
13172 super.CheckForRoofLimited(timeTresholdMS);
13173
13174 float time = GetGame().GetTime();
13175 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
13176 {
13177 m_PreviousRoofTestTime = time;
13178 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
13179 }
13180 }
13181
13182 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
13183 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
13184 {
13185 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
13186 {
13187 return 0;
13188 }
13189
13190 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
13191 {
13192 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
13193 if (filter)
13194 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
13195 else
13196 return 0;//otherwise return 0 when no filter attached
13197 }
13198
13199 string subclassPath, entryName;
13200
13201 switch (type)
13202 {
13203 case DEF_BIOLOGICAL:
13204 entryName = "biological";
13205 break;
13206 case DEF_CHEMICAL:
13207 entryName = "chemical";
13208 break;
13209 default:
13210 entryName = "biological";
13211 break;
13212 }
13213
13214 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
13215
13216 return GetGame().ConfigGetFloat(subclassPath + entryName);
13217 }
13218
13219
13220
13222 override void EEOnCECreate()
13223 {
13224 if (!IsMagazine())
13226
13228 }
13229
13230
13231 //-------------------------
13232 // OPEN/CLOSE USER ACTIONS
13233 //-------------------------
13235 void Open();
13236 void Close();
13237 bool IsOpen()
13238 {
13239 return true;
13240 }
13241
13242 override bool CanDisplayCargo()
13243 {
13244 return IsOpen();
13245 }
13246
13247
13248 // ------------------------------------------------------------
13249 // CONDITIONS
13250 // ------------------------------------------------------------
13251 override bool CanPutInCargo(EntityAI parent)
13252 {
13253 if (parent)
13254 {
13255 if (parent.IsInherited(DayZInfected))
13256 return true;
13257
13258 if (!parent.IsRuined())
13259 return true;
13260 }
13261
13262 return true;
13263 }
13264
13265 override bool CanPutAsAttachment(EntityAI parent)
13266 {
13267 if (!super.CanPutAsAttachment(parent))
13268 {
13269 return false;
13270 }
13271
13272 if (!IsRuined() && !parent.IsRuined())
13273 {
13274 return true;
13275 }
13276
13277 return false;
13278 }
13279
13280 override bool CanReceiveItemIntoCargo(EntityAI item)
13281 {
13282 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13283 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13284 // return false;
13285
13286 return super.CanReceiveItemIntoCargo(item);
13287 }
13288
13289 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
13290 {
13291 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13292 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13293 // return false;
13294
13295 GameInventory attachmentInv = attachment.GetInventory();
13296 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13297 {
13298 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13299 return false;
13300 }
13301
13302 InventoryLocation loc = new InventoryLocation();
13303 attachment.GetInventory().GetCurrentInventoryLocation(loc);
13304 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
13305 return false;
13306
13307 return super.CanReceiveAttachment(attachment, slotId);
13308 }
13309
13310 override bool CanReleaseAttachment(EntityAI attachment)
13311 {
13312 if (!super.CanReleaseAttachment(attachment))
13313 return false;
13314
13315 return GetInventory().AreChildrenAccessible();
13316 }
13317
13318 /*override bool CanLoadAttachment(EntityAI attachment)
13319 {
13320 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13321 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13322 // return false;
13323
13324 GameInventory attachmentInv = attachment.GetInventory();
13325 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13326 {
13327 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
13328 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
13329
13330 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13331 return false;
13332 }
13333
13334 return super.CanLoadAttachment(attachment);
13335 }*/
13336
13337 // Plays muzzle flash particle effects
13338 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13339 {
13340 int id = muzzle_owner.GetMuzzleID();
13341 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
13342
13343 if (WPOF_array)
13344 {
13345 for (int i = 0; i < WPOF_array.Count(); i++)
13346 {
13347 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
13348
13349 if (WPOF)
13350 {
13351 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
13352 }
13353 }
13354 }
13355 }
13356
13357 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
13358 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13359 {
13360 int id = muzzle_owner.GetMuzzleID();
13361 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
13362
13363 if (WPOBE_array)
13364 {
13365 for (int i = 0; i < WPOBE_array.Count(); i++)
13366 {
13367 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
13368
13369 if (WPOBE)
13370 {
13371 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13372 }
13373 }
13374 }
13375 }
13376
13377 // Plays all weapon overheating particles
13378 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13379 {
13380 int id = muzzle_owner.GetMuzzleID();
13381 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13382
13383 if (WPOOH_array)
13384 {
13385 for (int i = 0; i < WPOOH_array.Count(); i++)
13386 {
13387 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13388
13389 if (WPOOH)
13390 {
13391 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13392 }
13393 }
13394 }
13395 }
13396
13397 // Updates all weapon overheating particles
13398 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13399 {
13400 int id = muzzle_owner.GetMuzzleID();
13401 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13402
13403 if (WPOOH_array)
13404 {
13405 for (int i = 0; i < WPOOH_array.Count(); i++)
13406 {
13407 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13408
13409 if (WPOOH)
13410 {
13411 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13412 }
13413 }
13414 }
13415 }
13416
13417 // Stops overheating particles
13418 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13419 {
13420 int id = muzzle_owner.GetMuzzleID();
13421 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13422
13423 if (WPOOH_array)
13424 {
13425 for (int i = 0; i < WPOOH_array.Count(); i++)
13426 {
13427 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13428
13429 if (WPOOH)
13430 {
13431 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13432 }
13433 }
13434 }
13435 }
13436
13437 //----------------------------------------------------------------
13438 //Item Behaviour - unified approach
13439 override bool IsHeavyBehaviour()
13440 {
13441 if (m_ItemBehaviour == 0)
13442 {
13443 return true;
13444 }
13445
13446 return false;
13447 }
13448
13449 override bool IsOneHandedBehaviour()
13450 {
13451 if (m_ItemBehaviour == 1)
13452 {
13453 return true;
13454 }
13455
13456 return false;
13457 }
13458
13459 override bool IsTwoHandedBehaviour()
13460 {
13461 if (m_ItemBehaviour == 2)
13462 {
13463 return true;
13464 }
13465
13466 return false;
13467 }
13468
13469 bool IsDeployable()
13470 {
13471 return false;
13472 }
13473
13475 float GetDeployTime()
13476 {
13477 return UATimeSpent.DEFAULT_DEPLOY;
13478 }
13479
13480
13481 //----------------------------------------------------------------
13482 // Item Targeting (User Actions)
13483 override void SetTakeable(bool pState)
13484 {
13485 m_IsTakeable = pState;
13486 SetSynchDirty();
13487 }
13488
13489 override bool IsTakeable()
13490 {
13491 return m_IsTakeable;
13492 }
13493
13494 // For cases where we want to show object widget which cant be taken to hands
13496 {
13497 return false;
13498 }
13499
13501 protected void PreLoadSoundAttachmentType()
13502 {
13503 string att_type = "None";
13504
13505 if (ConfigIsExisting("soundAttType"))
13506 {
13507 att_type = ConfigGetString("soundAttType");
13508 }
13509
13510 m_SoundAttType = att_type;
13511 }
13512
13513 override string GetAttachmentSoundType()
13514 {
13515 return m_SoundAttType;
13516 }
13517
13518 //----------------------------------------------------------------
13519 //SOUNDS - ItemSoundHandler
13520 //----------------------------------------------------------------
13521
13522 string GetPlaceSoundset(); // played when deploy starts
13523 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13524 string GetDeploySoundset(); // played when deploy sucessfully finishes
13525 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13526 string GetFoldSoundset(); // played when fold sucessfully finishes
13527
13529 {
13530 if (!m_ItemSoundHandler)
13532
13533 return m_ItemSoundHandler;
13534 }
13535
13536 // override to initialize sounds
13537 protected void InitItemSounds()
13538 {
13539 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
13540 return;
13541
13543
13544 if (GetPlaceSoundset() != string.Empty)
13545 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13546
13547 if (GetDeploySoundset() != string.Empty)
13548 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13549
13550 SoundParameters params = new SoundParameters();
13551 params.m_Loop = true;
13552 if (GetLoopDeploySoundset() != string.Empty)
13553 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13554 }
13555
13556 // Start sound using ItemSoundHandler
13557 void StartItemSoundServer(int id)
13558 {
13559 if (!GetGame().IsServer())
13560 return;
13561
13562 m_SoundSyncPlay = id;
13563 SetSynchDirty();
13564
13565 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13567 }
13568
13569 // Stop sound using ItemSoundHandler
13570 void StopItemSoundServer(int id)
13571 {
13572 if (!GetGame().IsServer())
13573 return;
13574
13575 m_SoundSyncStop = id;
13576 SetSynchDirty();
13577
13578 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13580 }
13581
13582 protected void ClearStartItemSoundServer()
13583 {
13584 m_SoundSyncPlay = 0;
13585 }
13586
13587 protected void ClearStopItemSoundServer()
13588 {
13589 m_SoundSyncStop = 0;
13590 }
13591
13593 void PlayAttachSound(string slot_type)
13594 {
13595 if (!GetGame().IsDedicatedServer())
13596 {
13597 if (ConfigIsExisting("attachSoundSet"))
13598 {
13599 string cfg_path = "";
13600 string soundset = "";
13601 string type_name = GetType();
13602
13603 TStringArray cfg_soundset_array = new TStringArray;
13604 TStringArray cfg_slot_array = new TStringArray;
13605 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13606 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13607
13608 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13609 {
13610 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13611 {
13612 if (cfg_slot_array[i] == slot_type)
13613 {
13614 soundset = cfg_soundset_array[i];
13615 break;
13616 }
13617 }
13618 }
13619
13620 if (soundset != "")
13621 {
13622 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13623 sound.SetAutodestroy(true);
13624 }
13625 }
13626 }
13627 }
13628
13629 void PlayDetachSound(string slot_type)
13630 {
13631 //TODO - evaluate if needed and devise universal config structure if so
13632 }
13633
13634 void OnApply(PlayerBase player);
13635
13637 {
13638 return 1.0;
13639 };
13640 //returns applicable selection
13641 array<string> GetHeadHidingSelection()
13642 {
13644 }
13645
13647 {
13649 }
13650
13651 WrittenNoteData GetWrittenNoteData() {};
13652
13654 {
13655 SetDynamicPhysicsLifeTime(0.01);
13656 m_ItemBeingDroppedPhys = false;
13657 }
13658
13660 {
13661 array<string> zone_names = new array<string>;
13662 GetDamageZones(zone_names);
13663 for (int i = 0; i < zone_names.Count(); i++)
13664 {
13665 SetHealthMax(zone_names.Get(i),"Health");
13666 }
13667 SetHealthMax("","Health");
13668 }
13669
13671 void SetZoneDamageCEInit()
13672 {
13673 float global_health = GetHealth01("","Health");
13674 array<string> zones = new array<string>;
13675 GetDamageZones(zones);
13676 //set damage of all zones to match global health level
13677 for (int i = 0; i < zones.Count(); i++)
13678 {
13679 SetHealth01(zones.Get(i),"Health",global_health);
13680 }
13681 }
13682
13684 bool IsCoverFaceForShave(string slot_name)
13685 {
13686 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13687 }
13688
13689 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13690 {
13691 if (!hasRootAsPlayer)
13692 {
13693 if (refParentIB)
13694 {
13695 // parent is wet
13696 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13697 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13698 // parent has liquid inside
13699 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13700 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13701 // drying
13702 else if (m_VarWet > m_VarWetMin)
13703 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13704 }
13705 else
13706 {
13707 // drying on ground or inside non-itembase (car, ...)
13708 if (m_VarWet > m_VarWetMin)
13709 AddWet(-1 * delta * GetDryingIncrement("ground"));
13710 }
13711 }
13712 }
13713
13714 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13715 {
13717 {
13718 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13719 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13720 {
13721 float heatPermCoef = 1.0;
13722 EntityAI ent = this;
13723 while (ent)
13724 {
13725 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13726 ent = ent.GetHierarchyParent();
13727 }
13728
13729 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13730 }
13731 }
13732 }
13733
13734 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13735 {
13736 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13737 EntityAI parent = GetHierarchyParent();
13738 if (!parent)
13739 {
13740 hasParent = false;
13741 hasRootAsPlayer = false;
13742 }
13743 else
13744 {
13745 hasParent = true;
13746 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13747 refParentIB = ItemBase.Cast(parent);
13748 }
13749 }
13750
13751 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13752 {
13753 // this is stub, implemented on Edible_Base
13754 }
13755
13756 bool CanDecay()
13757 {
13758 // return true used on selected food clases so they can decay
13759 return false;
13760 }
13761
13762 protected bool CanProcessDecay()
13763 {
13764 // this is stub, implemented on Edible_Base class
13765 // used to determine whether it is still necessary for the food to decay
13766 return false;
13767 }
13768
13769 protected bool CanHaveWetness()
13770 {
13771 // return true used on selected items that have a wetness effect
13772 return false;
13773 }
13774
13776 bool CanBeConsumed(ConsumeConditionData data = null)
13777 {
13778 return !GetIsFrozen() && IsOpen();
13779 }
13780
13781 override void ProcessVariables()
13782 {
13783 bool hasParent = false, hasRootAsPlayer = false;
13784 ItemBase refParentIB;
13785
13786 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13787 bool foodDecay = g_Game.IsFoodDecayEnabled();
13788
13789 if (wwtu || foodDecay)
13790 {
13791 bool processWetness = wwtu && CanHaveWetness();
13792 bool processTemperature = wwtu && CanHaveTemperature();
13793 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13794
13795 if (processWetness || processTemperature || processDecay)
13796 {
13797 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13798
13799 if (processWetness)
13800 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13801
13802 if (processTemperature)
13803 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13804
13805 if (processDecay)
13806 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13807 }
13808 }
13809 }
13810
13813 {
13814 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13815 }
13816
13817 override float GetTemperatureFreezeThreshold()
13818 {
13820 return Liquid.GetFreezeThreshold(GetLiquidType());
13821
13822 return super.GetTemperatureFreezeThreshold();
13823 }
13824
13825 override float GetTemperatureThawThreshold()
13826 {
13828 return Liquid.GetThawThreshold(GetLiquidType());
13829
13830 return super.GetTemperatureThawThreshold();
13831 }
13832
13833 override float GetItemOverheatThreshold()
13834 {
13836 return Liquid.GetBoilThreshold(GetLiquidType());
13837
13838 return super.GetItemOverheatThreshold();
13839 }
13840
13841 override float GetTemperatureFreezeTime()
13842 {
13843 if (HasQuantity())
13844 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13845
13846 return super.GetTemperatureFreezeTime();
13847 }
13848
13849 override float GetTemperatureThawTime()
13850 {
13851 if (HasQuantity())
13852 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13853
13854 return super.GetTemperatureThawTime();
13855 }
13856
13858 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13860 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13861
13862 bool IsCargoException4x3(EntityAI item)
13863 {
13864 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13865 }
13866
13868 {
13869 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13870 }
13871
13873 void AddLightSourceItem(ItemBase lightsource)
13874 {
13875 m_LightSourceItem = lightsource;
13876 }
13877
13879 {
13880 m_LightSourceItem = null;
13881 }
13882
13884 {
13885 return m_LightSourceItem;
13886 }
13887
13889 array<int> GetValidFinishers()
13890 {
13891 return null;
13892 }
13893
13895 bool GetActionWidgetOverride(out typename name)
13896 {
13897 return false;
13898 }
13899
13900 bool PairWithDevice(notnull ItemBase otherDevice)
13901 {
13902 if (GetGame().IsServer())
13903 {
13904 ItemBase explosive = otherDevice;
13906 if (!trg)
13907 {
13908 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13909 explosive = this;
13910 }
13911
13912 explosive.PairRemote(trg);
13913 trg.SetControlledDevice(explosive);
13914
13915 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13916 trg.SetPersistentPairID(persistentID);
13917 explosive.SetPersistentPairID(persistentID);
13918
13919 return true;
13920 }
13921 return false;
13922 }
13923
13925 float GetBaitEffectivity()
13926 {
13927 float ret = 1.0;
13928 if (HasQuantity())
13929 ret *= GetQuantityNormalized();
13930 ret *= GetHealth01();
13931
13932 return ret;
13933 }
13934
13935 #ifdef DEVELOPER
13936 override void SetDebugItem()
13937 {
13938 super.SetDebugItem();
13939 _itemBase = this;
13940 }
13941
13942 override string GetDebugText()
13943 {
13944 string text = super.GetDebugText();
13945
13946 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13947 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13948
13949 return text;
13950 }
13951 #endif
13952
13953 bool CanBeUsedForSuicide()
13954 {
13955 return true;
13956 }
13957
13959 //DEPRECATED BELOW
13961 // Backwards compatibility
13962 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13963 {
13964 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13965 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13966 }
13967
13968 // replaced by ItemSoundHandler
13969 protected EffectSound m_SoundDeployFinish;
13970 protected EffectSound m_SoundPlace;
13971 protected EffectSound m_DeployLoopSoundEx;
13972 protected EffectSound m_SoundDeploy;
13973 bool m_IsPlaceSound;
13974 bool m_IsDeploySound;
13976
13977 string GetDeployFinishSoundset();
13978 void PlayDeploySound();
13979 void PlayDeployFinishSound();
13980 void PlayPlaceSound();
13981 void PlayDeployLoopSoundEx();
13982 void StopDeployLoopSoundEx();
13983 void SoundSynchRemoteReset();
13984 void SoundSynchRemote();
13985 bool UsesGlobalDeploy(){return false;}
13986 bool CanPlayDeployLoopSound(){return false;}
13988 bool IsPlaceSound(){return m_IsPlaceSound;}
13989 bool IsDeploySound(){return m_IsDeploySound;}
13990 void SetIsPlaceSound(bool is_place_sound);
13991 void SetIsDeploySound(bool is_deploy_sound);
13992}
13993
13994EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13995{
13996 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13997 if (entity)
13998 {
13999 bool is_item = entity.IsInherited(ItemBase);
14000 if (is_item && full_quantity)
14001 {
14002 ItemBase item = ItemBase.Cast(entity);
14003 item.SetQuantity(item.GetQuantityInit());
14004 }
14005 }
14006 else
14007 {
14008 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
14009 return NULL;
14010 }
14011 return entity;
14012}
14013
14014void SetupSpawnedItem(ItemBase item, float health, float quantity)
14015{
14016 if (item)
14017 {
14018 if (health > 0)
14019 item.SetHealth("", "", health);
14020
14021 if (item.CanHaveTemperature())
14022 {
14023 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
14024 if (item.CanFreeze())
14025 item.SetFrozen(false);
14026 }
14027
14028 if (item.HasEnergyManager())
14029 {
14030 if (quantity >= 0)
14031 {
14032 item.GetCompEM().SetEnergy0To1(quantity);
14033 }
14034 else
14035 {
14036 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
14037 }
14038 }
14039 else if (item.IsMagazine())
14040 {
14041 Magazine mag = Magazine.Cast(item);
14042 if (quantity >= 0)
14043 {
14044 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
14045 }
14046 else
14047 {
14048 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
14049 }
14050
14051 }
14052 else
14053 {
14054 if (quantity >= 0)
14055 {
14056 item.SetQuantityNormalized(quantity, false);
14057 }
14058 else
14059 {
14060 item.SetQuantity(Math.AbsFloat(quantity));
14061 }
14062
14063 }
14064 }
14065}
14066
14067#ifdef DEVELOPER
14068ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
14069#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()

Используется в Start().