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

◆ PlayDetachSound()

void SpawnItemOnLocation::PlayDetachSound ( string slot_type)
protected

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

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