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

◆ CanDecay()

BrisketSpread Edible_Base CanDecay ( )
protected

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

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