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

◆ ProcessItemTemperature()

void SpawnItemOnLocation::ProcessItemTemperature ( float delta,
bool hasParent,
bool hasRootAsPlayer,
ItemBase refParentIB )
protected

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

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

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