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

◆ OnEnergyConsumed()

override void SpawnItemOnLocation::OnEnergyConsumed ( )
protected

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

8541{
8542 override bool CanPutAsAttachment(EntityAI parent)
8543 {
8544 return true;
8545 }
8546};
8547
8549{
8550
8551};
8552
8553//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8554
8555class ItemBase extends InventoryItem
8556{
8560
8562
8563 static int m_DebugActionsMask;
8565 // ============================================
8566 // Variable Manipulation System
8567 // ============================================
8568 // Quantity
8569
8570 float m_VarQuantity;
8571 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8573 int m_VarQuantityMin;
8574 int m_VarQuantityMax;
8575 int m_Count;
8576 float m_VarStackMax;
8577 float m_StoreLoadedQuantity = float.LOWEST;
8578 // Wet
8579 float m_VarWet;
8580 float m_VarWetPrev;//for client to know wetness changed during synchronization
8581 float m_VarWetInit;
8582 float m_VarWetMin;
8583 float m_VarWetMax;
8584 // Cleanness
8585 int m_Cleanness;
8586 int m_CleannessInit;
8587 int m_CleannessMin;
8588 int m_CleannessMax;
8589 // impact sounds
8591 bool m_CanPlayImpactSound = true;
8592 float m_ImpactSpeed;
8594 //
8595 float m_HeatIsolation;
8596 float m_ItemModelLength;
8597 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8599 int m_VarLiquidType;
8600 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8601 int m_QuickBarBonus;
8602 bool m_IsBeingPlaced;
8603 bool m_IsHologram;
8604 bool m_IsTakeable;
8605 bool m_ThrowItemOnDrop;
8608 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8609 bool can_this_be_combined; //Check if item can be combined
8610 bool m_CanThisBeSplit; //Check if item can be split
8611 bool m_IsStoreLoad = false;
8612 bool m_CanShowQuantity;
8613 bool m_HasQuantityBar;
8614 protected bool m_CanBeDigged;
8615 protected bool m_IsResultOfSplit
8616
8617 string m_SoundAttType;
8618 // items color variables
8623 //-------------------------------------------------------
8624
8625 // light source managing
8627
8631
8632 //==============================================
8633 // agent system
8634 private int m_AttachedAgents;
8635
8637 void TransferModifiers(PlayerBase reciever);
8638
8639
8640 // Weapons & suppressors particle effects
8644 ref static map<string, int> m_WeaponTypeToID;
8645 static int m_LastRegisteredWeaponID = 0;
8646
8647 // Overheating effects
8649 float m_OverheatingShots;
8650 ref Timer m_CheckOverheating;
8651 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8652 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8653 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8654 ref array <ref OverheatingParticle> m_OverheatingParticles;
8655
8657 protected bool m_HideSelectionsBySlot;
8658
8659 // Admin Log
8660 PluginAdminLog m_AdminLog;
8661
8662 // misc
8663 ref Timer m_PhysDropTimer;
8664
8665 // Attachment Locking variables
8666 ref array<int> m_CompatibleLocks;
8667 protected int m_LockType;
8668 protected ref EffectSound m_LockingSound;
8669 protected string m_LockSoundSet;
8670
8671 // ItemSoundHandler variables
8672 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8673 protected int m_SoundSyncPlay; // id for sound to play
8674 protected int m_SoundSyncStop; // id for sound to stop
8675 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
8676
8678
8679 //temperature
8680 private float m_TemperaturePerQuantityWeight;
8681
8682 // -------------------------------------------------------------------------
8683 void ItemBase()
8684 {
8685 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8689
8690 if (!g_Game.IsDedicatedServer())
8691 {
8692 if (HasMuzzle())
8693 {
8695
8697 {
8699 }
8700 }
8701
8703 m_ActionsInitialize = false;
8704 }
8705
8706 m_OldLocation = null;
8707
8708 if (g_Game.IsServer())
8709 {
8710 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8711 }
8712
8713 if (ConfigIsExisting("headSelectionsToHide"))
8714 {
8716 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8717 }
8718
8719 m_HideSelectionsBySlot = false;
8720 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8721 {
8722 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8723 }
8724
8725 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8726
8727 m_IsResultOfSplit = false;
8728
8730 }
8731
8732 override void InitItemVariables()
8733 {
8734 super.InitItemVariables();
8735
8736 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8737 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8738 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8739 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8740 m_VarStackMax = ConfigGetFloat("varStackMax");
8741 m_Count = ConfigGetInt("count");
8742
8743 m_CanShowQuantity = ConfigGetBool("quantityShow");
8744 m_HasQuantityBar = ConfigGetBool("quantityBar");
8745
8746 m_CleannessInit = ConfigGetInt("varCleannessInit");
8748 m_CleannessMin = ConfigGetInt("varCleannessMin");
8749 m_CleannessMax = ConfigGetInt("varCleannessMax");
8750
8751 m_WantPlayImpactSound = false;
8752 m_ImpactSpeed = 0.0;
8753
8754 m_VarWetInit = ConfigGetFloat("varWetInit");
8756 m_VarWetMin = ConfigGetFloat("varWetMin");
8757 m_VarWetMax = ConfigGetFloat("varWetMax");
8758
8759 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8760 if (IsLiquidContainer() && GetQuantity() != 0)
8762 m_IsBeingPlaced = false;
8763 m_IsHologram = false;
8764 m_IsTakeable = true;
8765 m_CanBeMovedOverride = false;
8769 m_CanBeDigged = ConfigGetBool("canBeDigged");
8770
8771 m_CompatibleLocks = new array<int>();
8772 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8773 m_LockType = ConfigGetInt("lockType");
8774
8775 //Define if item can be split and set ability to be combined accordingly
8776 m_CanThisBeSplit = false;
8777 can_this_be_combined = false;
8778 if (ConfigIsExisting("canBeSplit"))
8779 {
8780 can_this_be_combined = ConfigGetBool("canBeSplit");
8782 }
8783
8784 m_ItemBehaviour = -1;
8785 if (ConfigIsExisting("itemBehaviour"))
8786 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8787
8788 //RegisterNetSyncVariableInt("m_VariablesMask");
8789 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8790 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8791 RegisterNetSyncVariableInt("m_VarLiquidType");
8792 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8793
8794 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8795 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8796 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8797
8798 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8799 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8800 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8801 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8802
8803 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8804 RegisterNetSyncVariableBool("m_IsTakeable");
8805 RegisterNetSyncVariableBool("m_IsHologram");
8806
8809 {
8810 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8811 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8812 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
8813 }
8814
8815 m_LockSoundSet = ConfigGetString("lockSoundSet");
8816
8818 if (ConfigIsExisting("temperaturePerQuantityWeight"))
8819 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
8820
8821 m_SoundSyncSlotID = -1;
8822 }
8823
8824 override int GetQuickBarBonus()
8825 {
8826 return m_QuickBarBonus;
8827 }
8828
8829 void InitializeActions()
8830 {
8832 if (!m_InputActionMap)
8833 {
8835 m_InputActionMap = iam;
8836 SetActions();
8838 }
8839 }
8840
8841 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
8842 {
8844 {
8845 m_ActionsInitialize = true;
8847 }
8848
8849 actions = m_InputActionMap.Get(action_input_type);
8850 }
8851
8852 void SetActions()
8853 {
8854 AddAction(ActionTakeItem);
8855 AddAction(ActionTakeItemToHands);
8856 AddAction(ActionWorldCraft);
8858 AddAction(ActionAttachWithSwitch);
8859 }
8860
8861 void SetActionAnimOverrides(); // Override action animation for specific item
8862
8863 void AddAction(typename actionName)
8864 {
8865 ActionBase action = ActionManagerBase.GetAction(actionName);
8866
8867 if (!action)
8868 {
8869 Debug.LogError("Action " + actionName + " dosn't exist!");
8870 return;
8871 }
8872
8873 typename ai = action.GetInputType();
8874 if (!ai)
8875 {
8876 m_ActionsInitialize = false;
8877 return;
8878 }
8879
8880 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8881 if (!action_array)
8882 {
8883 action_array = new array<ActionBase_Basic>;
8884 m_InputActionMap.Insert(ai, action_array);
8885 }
8886 if (LogManager.IsActionLogEnable())
8887 {
8888 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
8889 }
8890
8891 if (action_array.Find(action) != -1)
8892 {
8893 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
8894 }
8895 else
8896 {
8897 action_array.Insert(action);
8898 }
8899 }
8900
8901 void RemoveAction(typename actionName)
8902 {
8903 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8904 ActionBase action = player.GetActionManager().GetAction(actionName);
8905 typename ai = action.GetInputType();
8906 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8907
8908 if (action_array)
8909 {
8910 action_array.RemoveItem(action);
8911 }
8912 }
8913
8914 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
8915 // Set -1 for params which should stay in default state
8916 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
8917 {
8918 ActionOverrideData overrideData = new ActionOverrideData();
8919 overrideData.m_CommandUID = commandUID;
8920 overrideData.m_CommandUIDProne = commandUIDProne;
8921 overrideData.m_StanceMask = stanceMask;
8922
8923 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
8924 if (!actionMap) // create new map of action > overidables map
8925 {
8926 actionMap = new TActionAnimOverrideMap();
8927 m_ItemActionOverrides.Insert(action, actionMap);
8928 }
8929
8930 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
8931
8932 }
8933
8934 void OnItemInHandsPlayerSwimStart(PlayerBase player);
8935
8936 ScriptedLightBase GetLight();
8937
8938 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8939 void LoadParticleConfigOnFire(int id)
8940 {
8941 if (!m_OnFireEffect)
8943
8946
8947 string config_to_search = "CfgVehicles";
8948 string muzzle_owner_config;
8949
8950 if (!m_OnFireEffect.Contains(id))
8951 {
8952 if (IsInherited(Weapon))
8953 config_to_search = "CfgWeapons";
8954
8955 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8956
8957 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
8958
8959 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
8960
8961 if (config_OnFire_subclass_count > 0)
8962 {
8963 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
8964
8965 for (int i = 0; i < config_OnFire_subclass_count; i++)
8966 {
8967 string particle_class = "";
8968 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
8969 string config_OnFire_entry = config_OnFire_class + particle_class;
8970 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
8971 WPOF_array.Insert(WPOF);
8972 }
8973
8974
8975 m_OnFireEffect.Insert(id, WPOF_array);
8976 }
8977 }
8978
8979 if (!m_OnBulletCasingEjectEffect.Contains(id))
8980 {
8981 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
8982 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8983
8984 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
8985
8986 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
8987
8988 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
8989 {
8990 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
8991
8992 for (i = 0; i < config_OnBulletCasingEject_count; i++)
8993 {
8994 string particle_class2 = "";
8995 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
8996 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
8997 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
8998 WPOBE_array.Insert(WPOBE);
8999 }
9000
9001
9002 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9003 }
9004 }
9005 }
9006
9007 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9009 {
9012
9013 if (!m_OnOverheatingEffect.Contains(id))
9014 {
9015 string config_to_search = "CfgVehicles";
9016
9017 if (IsInherited(Weapon))
9018 config_to_search = "CfgWeapons";
9019
9020 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9021 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9022
9023 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
9024 {
9025
9026 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9027
9029 {
9030 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9031 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9032 Error(error);
9033 return;
9034 }
9035
9036 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9037 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9038
9039
9040
9041 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
9042 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9043
9044 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9045 {
9046 string particle_class = "";
9047 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9048 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9049 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
9050
9051 if (entry_type == CT_CLASS)
9052 {
9053 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9054 WPOOH_array.Insert(WPOF);
9055 }
9056 }
9057
9058
9059 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9060 }
9061 }
9062 }
9063
9064 float GetOverheatingValue()
9065 {
9066 return m_OverheatingShots;
9067 }
9068
9069 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9070 {
9071 if (m_MaxOverheatingValue > 0)
9072 {
9074
9075 if (!m_CheckOverheating)
9077
9079 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9080
9081 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9082 }
9083 }
9084
9085 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9086 {
9088 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9089
9091 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9092
9094 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9095
9097 {
9099 }
9100 }
9101
9103 {
9105 }
9106
9107 void OnOverheatingDecay()
9108 {
9109 if (m_MaxOverheatingValue > 0)
9110 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9111 else
9113
9114 if (m_OverheatingShots <= 0)
9115 {
9118 }
9119 else
9120 {
9121 if (!m_CheckOverheating)
9123
9125 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9126 }
9127
9128 CheckOverheating(this, "", this);
9129 }
9130
9131 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9132 {
9134 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9135 }
9136
9137 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9138 {
9140 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9142 }
9143
9144 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9145 {
9147 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9148 }
9149
9150 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9151 {
9153 m_OverheatingParticles = new array<ref OverheatingParticle>;
9154
9155 OverheatingParticle OP = new OverheatingParticle();
9156 OP.RegisterParticle(p);
9157 OP.SetOverheatingLimitMin(min_heat_coef);
9158 OP.SetOverheatingLimitMax(max_heat_coef);
9159 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9160
9161 m_OverheatingParticles.Insert(OP);
9162 }
9163
9164 float GetOverheatingCoef()
9165 {
9166 if (m_MaxOverheatingValue > 0)
9168
9169 return -1;
9170 }
9171
9173 {
9175 {
9176 float overheat_coef = GetOverheatingCoef();
9177 int count = m_OverheatingParticles.Count();
9178
9179 for (int i = count; i > 0; --i)
9180 {
9181 int id = i - 1;
9182 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9183 Particle p = OP.GetParticle();
9184
9185 float overheat_min = OP.GetOverheatingLimitMin();
9186 float overheat_max = OP.GetOverheatingLimitMax();
9187
9188 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9189 {
9190 if (p)
9191 {
9192 p.Stop();
9193 OP.RegisterParticle(null);
9194 }
9195 }
9196 }
9197 }
9198 }
9199
9201 {
9203 {
9204 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9205 {
9206 int id = i - 1;
9207 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9208
9209 if (OP)
9210 {
9211 Particle p = OP.GetParticle();
9212
9213 if (p)
9214 {
9215 p.Stop();
9216 }
9217
9218 delete OP;
9219 }
9220 }
9221
9222 m_OverheatingParticles.Clear();
9224 }
9225 }
9226
9228 float GetInfectionChance(int system = 0, Param param = null)
9229 {
9230 return 0.0;
9231 }
9232
9233
9234 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9235 {
9236 return 250;//default value
9237 }
9238
9239 float GetFilterDamageRatio()
9240 {
9241 return 0;
9242 }
9243
9245 bool HasMuzzle()
9246 {
9247 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9248 return true;
9249
9250 return false;
9251 }
9252
9254 int GetMuzzleID()
9255 {
9256 if (!m_WeaponTypeToID)
9257 m_WeaponTypeToID = new map<string, int>;
9258
9259 if (m_WeaponTypeToID.Contains(GetType()))
9260 {
9261 return m_WeaponTypeToID.Get(GetType());
9262 }
9263 else
9264 {
9265 // Register new weapon ID
9267 }
9268
9270 }
9271
9278 {
9279 return -1;
9280 }
9281
9282
9283
9284 // -------------------------------------------------------------------------
9285 void ~ItemBase()
9286 {
9287 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
9288 {
9289 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9290 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9291
9292 if (r_index >= 0)
9293 {
9294 InventoryLocation r_il = new InventoryLocation;
9295 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9296
9297 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9298 int r_type = r_il.GetType();
9299 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9300 {
9301 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9302 }
9303 else if (r_type == InventoryLocationType.ATTACHMENT)
9304 {
9305 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9306 }
9307
9308 }
9309
9310 player.GetHumanInventory().ClearUserReservedLocation(this);
9311 }
9312
9313 if (m_LockingSound)
9314 SEffectManager.DestroyEffect(m_LockingSound);
9315 }
9316
9317
9318
9319 // -------------------------------------------------------------------------
9320 static int GetDebugActionsMask()
9321 {
9322 return ItemBase.m_DebugActionsMask;
9323 }
9324
9325 static bool HasDebugActionsMask(int mask)
9326 {
9327 return ItemBase.m_DebugActionsMask & mask;
9328 }
9329
9330 static void SetDebugActionsMask(int mask)
9331 {
9332 ItemBase.m_DebugActionsMask = mask;
9333 }
9334
9335 static void AddDebugActionsMask(int mask)
9336 {
9337 ItemBase.m_DebugActionsMask |= mask;
9338 }
9339
9340 static void RemoveDebugActionsMask(int mask)
9341 {
9342 ItemBase.m_DebugActionsMask &= ~mask;
9343 }
9344
9345 static void ToggleDebugActionsMask(int mask)
9346 {
9347 if (HasDebugActionsMask(mask))
9348 {
9350 }
9351 else
9352 {
9353 AddDebugActionsMask(mask);
9354 }
9355 }
9356
9357 // -------------------------------------------------------------------------
9358 void SetCEBasedQuantity()
9359 {
9360 if (GetEconomyProfile())
9361 {
9362 float q_max = GetEconomyProfile().GetQuantityMax();
9363 if (q_max > 0)
9364 {
9365 float q_min = GetEconomyProfile().GetQuantityMin();
9366 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9367
9368 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9369 {
9370 ComponentEnergyManager comp = GetCompEM();
9371 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
9372 {
9373 comp.SetEnergy0To1(quantity_randomized);
9374 }
9375 }
9376 else if (HasQuantity())
9377 {
9378 SetQuantityNormalized(quantity_randomized, false);
9379 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9380 }
9381
9382 }
9383 }
9384 }
9385
9387 void LockToParent()
9388 {
9389 EntityAI parent = GetHierarchyParent();
9390
9391 if (parent)
9392 {
9393 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9394 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9395 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9396 }
9397 }
9398
9400 void UnlockFromParent()
9401 {
9402 EntityAI parent = GetHierarchyParent();
9403
9404 if (parent)
9405 {
9406 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9407 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9408 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9409 }
9410 }
9411
9412 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9413 {
9414 /*
9415 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9416 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
9417 */
9418 ItemBase item2 = ItemBase.Cast(entity2);
9419
9420 if (g_Game.IsClient())
9421 {
9422 if (ScriptInputUserData.CanStoreInputUserData())
9423 {
9424 ScriptInputUserData ctx = new ScriptInputUserData;
9426 ctx.Write(-1);
9427 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9428 ctx.Write(i1);
9429 ctx.Write(item2);
9430 ctx.Write(use_stack_max);
9431 ctx.Write(-1);
9432 ctx.Send();
9433
9434 if (IsCombineAll(item2, use_stack_max))
9435 {
9436 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9437 }
9438 }
9439 }
9440 else if (!g_Game.IsMultiplayer())
9441 {
9442 CombineItems(item2, use_stack_max);
9443 }
9444 }
9445
9446 bool IsLiquidPresent()
9447 {
9448 return (GetLiquidType() != 0 && HasQuantity());
9449 }
9450
9451 bool IsLiquidContainer()
9452 {
9453 return m_LiquidContainerMask != 0;
9454 }
9455
9457 {
9458 return m_LiquidContainerMask;
9459 }
9460
9461 bool IsBloodContainer()
9462 {
9463 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9464 return false;
9465 }
9466
9467 bool IsNVG()
9468 {
9469 return false;
9470 }
9471
9474 bool IsExplosive()
9475 {
9476 return false;
9477 }
9478
9480 {
9481 return "";
9482 }
9483
9485
9486 bool IsLightSource()
9487 {
9488 return false;
9489 }
9490
9492 {
9493 return true;
9494 }
9495
9496 //--- ACTION CONDITIONS
9497 //direction
9498 bool IsFacingPlayer(PlayerBase player, string selection)
9499 {
9500 return true;
9501 }
9502
9503 bool IsPlayerInside(PlayerBase player, string selection)
9504 {
9505 return true;
9506 }
9507
9508 override bool CanObstruct()
9509 {
9510 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9511 return !player || !IsPlayerInside(player, "");
9512 }
9513
9514 override bool IsBeingPlaced()
9515 {
9516 return m_IsBeingPlaced;
9517 }
9518
9519 void SetIsBeingPlaced(bool is_being_placed)
9520 {
9521 m_IsBeingPlaced = is_being_placed;
9522 if (!is_being_placed)
9524 SetSynchDirty();
9525 }
9526
9527 //server-side
9528 void OnEndPlacement() {}
9529
9530 override bool IsHologram()
9531 {
9532 return m_IsHologram;
9533 }
9534
9535 bool CanBeDigged()
9536 {
9537 return m_CanBeDigged;
9538 }
9539
9541 {
9542 return 1;
9543 }
9544
9545 bool CanMakeGardenplot()
9546 {
9547 return false;
9548 }
9549
9550 void SetIsHologram(bool is_hologram)
9551 {
9552 m_IsHologram = is_hologram;
9553 SetSynchDirty();
9554 }
9555 /*
9556 protected float GetNutritionalEnergy()
9557 {
9558 Edible_Base edible = Edible_Base.Cast(this);
9559 return edible.GetFoodEnergy();
9560 }
9561
9562 protected float GetNutritionalWaterContent()
9563 {
9564 Edible_Base edible = Edible_Base.Cast(this);
9565 return edible.GetFoodWater();
9566 }
9567
9568 protected float GetNutritionalIndex()
9569 {
9570 Edible_Base edible = Edible_Base.Cast(this);
9571 return edible.GetFoodNutritionalIndex();
9572 }
9573
9574 protected float GetNutritionalFullnessIndex()
9575 {
9576 Edible_Base edible = Edible_Base.Cast(this);
9577 return edible.GetFoodTotalVolume();
9578 }
9579
9580 protected float GetNutritionalToxicity()
9581 {
9582 Edible_Base edible = Edible_Base.Cast(this);
9583 return edible.GetFoodToxicity();
9584
9585 }
9586 */
9587
9588
9589 // -------------------------------------------------------------------------
9590 override void OnMovedInsideCargo(EntityAI container)
9591 {
9592 super.OnMovedInsideCargo(container);
9593
9594 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9595 }
9596
9597 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9598 {
9599 super.EEItemLocationChanged(oldLoc, newLoc);
9600
9601 PlayerBase newPlayer = null;
9602 PlayerBase oldPlayer = null;
9603
9604 if (newLoc.GetParent())
9605 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9606
9607 if (oldLoc.GetParent())
9608 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9609
9610 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
9611 {
9612 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
9613
9614 if (rIndex >= 0)
9615 {
9616 InventoryLocation rIl = new InventoryLocation;
9617 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
9618
9619 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
9620 int rType = rIl.GetType();
9621 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
9622 {
9623 rIl.GetParent().GetOnReleaseLock().Invoke(this);
9624 }
9625 else if (rType == InventoryLocationType.ATTACHMENT)
9626 {
9627 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
9628 }
9629
9630 }
9631 }
9632
9633 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
9634 {
9635 if (newPlayer)
9636 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
9637
9638 if (newPlayer == oldPlayer)
9639 {
9640 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9641 {
9642 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9643 {
9644 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9645 {
9646 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9647 }
9648 }
9649 else
9650 {
9651 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9652 }
9653 }
9654
9655 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9656 {
9657 int type = oldLoc.GetType();
9658 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9659 {
9660 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9661 }
9662 else if (type == InventoryLocationType.ATTACHMENT)
9663 {
9664 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9665 }
9666 }
9667 if (!m_OldLocation)
9668 {
9669 m_OldLocation = new InventoryLocation;
9670 }
9671 m_OldLocation.Copy(oldLoc);
9672 }
9673 else
9674 {
9675 if (m_OldLocation)
9676 {
9677 m_OldLocation.Reset();
9678 }
9679 }
9680
9681 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
9682 }
9683 else
9684 {
9685 if (newPlayer)
9686 {
9687 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9688 if (resIndex >= 0)
9689 {
9690 InventoryLocation il = new InventoryLocation;
9691 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
9692 ItemBase it = ItemBase.Cast(il.GetItem());
9693 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
9694 int rel_type = il.GetType();
9695 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9696 {
9697 il.GetParent().GetOnReleaseLock().Invoke(it);
9698 }
9699 else if (rel_type == InventoryLocationType.ATTACHMENT)
9700 {
9701 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9702 }
9703 //it.GetOnReleaseLock().Invoke(it);
9704 }
9705 }
9706 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9707 {
9708 //ThrowPhysically(oldPlayer, vector.Zero);
9709 m_ThrowItemOnDrop = false;
9710 }
9711
9712 if (m_OldLocation)
9713 {
9714 m_OldLocation.Reset();
9715 }
9716 }
9717
9718 if (oldLoc.GetType() == InventoryLocationType.TEMP)
9719 {
9720 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
9721 }
9722
9723 if (newLoc.GetType() == InventoryLocationType.TEMP)
9724 {
9725 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
9726 }
9727 }
9728
9729 override void EOnContact(IEntity other, Contact extra)
9730 {
9732 {
9733 int liquidType = -1;
9734 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9735 if (impactSpeed > 0.0)
9736 {
9737 m_ImpactSpeed = impactSpeed;
9738 #ifndef SERVER
9739 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9740 #else
9741 m_WantPlayImpactSound = true;
9742 SetSynchDirty();
9743 #endif
9744 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9745 }
9746 }
9747
9748 #ifdef SERVER
9749 if (GetCompEM() && GetCompEM().IsPlugged())
9750 {
9751 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9752 GetCompEM().UnplugThis();
9753 }
9754 #endif
9755 }
9756
9757 void RefreshPhysics();
9758
9759 override void OnCreatePhysics()
9760 {
9762 }
9763
9764 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9765 {
9766
9767 }
9768 // -------------------------------------------------------------------------
9769 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9770 {
9771 super.OnItemLocationChanged(old_owner, new_owner);
9772
9773 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9774 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9775
9776 if (!relatedPlayer && playerNew)
9777 relatedPlayer = playerNew;
9778
9779 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9780 {
9781 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9782 if (actionMgr)
9783 {
9784 ActionBase currentAction = actionMgr.GetRunningAction();
9785 if (currentAction)
9786 currentAction.OnItemLocationChanged(this);
9787 }
9788 }
9789
9790 Man ownerPlayerOld = null;
9791 Man ownerPlayerNew = null;
9792
9793 if (old_owner)
9794 {
9795 if (old_owner.IsMan())
9796 {
9797 ownerPlayerOld = Man.Cast(old_owner);
9798 }
9799 else
9800 {
9801 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9802 }
9803 }
9804 else
9805 {
9806 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9807 {
9808 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9809
9810 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9811 {
9812 GetCompEM().UnplugThis();
9813 }
9814 }
9815 }
9816
9817 if (new_owner)
9818 {
9819 if (new_owner.IsMan())
9820 {
9821 ownerPlayerNew = Man.Cast(new_owner);
9822 }
9823 else
9824 {
9825 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
9826 }
9827 }
9828
9829 if (ownerPlayerOld != ownerPlayerNew)
9830 {
9831 if (ownerPlayerOld)
9832 {
9833 array<EntityAI> subItemsExit = new array<EntityAI>;
9834 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
9835 for (int i = 0; i < subItemsExit.Count(); i++)
9836 {
9837 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
9838 itemExit.OnInventoryExit(ownerPlayerOld);
9839 }
9840 }
9841
9842 if (ownerPlayerNew)
9843 {
9844 array<EntityAI> subItemsEnter = new array<EntityAI>;
9845 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
9846 for (int j = 0; j < subItemsEnter.Count(); j++)
9847 {
9848 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
9849 itemEnter.OnInventoryEnter(ownerPlayerNew);
9850 }
9851 }
9852 }
9853 else if (ownerPlayerNew != null)
9854 {
9855 PlayerBase nplayer;
9856 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
9857 {
9858 array<EntityAI> subItemsUpdate = new array<EntityAI>;
9859 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
9860 for (int k = 0; k < subItemsUpdate.Count(); k++)
9861 {
9862 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
9863 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
9864 }
9865 }
9866 }
9867
9868 if (old_owner)
9869 old_owner.OnChildItemRemoved(this);
9870 if (new_owner)
9871 new_owner.OnChildItemReceived(this);
9872 }
9873
9874 // -------------------------------------------------------------------------------
9875 override void EEDelete(EntityAI parent)
9876 {
9877 super.EEDelete(parent);
9878 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
9879 if (player)
9880 {
9881 OnInventoryExit(player);
9882
9883 if (player.IsAlive())
9884 {
9885 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9886 if (r_index >= 0)
9887 {
9888 InventoryLocation r_il = new InventoryLocation;
9889 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9890
9891 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9892 int r_type = r_il.GetType();
9893 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9894 {
9895 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9896 }
9897 else if (r_type == InventoryLocationType.ATTACHMENT)
9898 {
9899 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9900 }
9901
9902 }
9903
9904 player.RemoveQuickBarEntityShortcut(this);
9905 }
9906 }
9907 }
9908 // -------------------------------------------------------------------------------
9909 override void EEKilled(Object killer)
9910 {
9911 super.EEKilled(killer);
9912
9914 if (killer && killer.IsFireplace() && CanExplodeInFire())
9915 {
9916 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
9917 {
9918 if (IsMagazine())
9919 {
9920 if (Magazine.Cast(this).GetAmmoCount() > 0)
9921 {
9922 ExplodeAmmo();
9923 }
9924 }
9925 else
9926 {
9927 Explode(DamageType.EXPLOSION);
9928 }
9929 }
9930 }
9931 }
9932
9933 override void OnWasAttached(EntityAI parent, int slot_id)
9934 {
9935 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9936
9937 super.OnWasAttached(parent, slot_id);
9938
9939 if (HasQuantity())
9940 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9941
9942 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9943 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
9944 }
9945
9946 override void OnWasDetached(EntityAI parent, int slot_id)
9947 {
9948 super.OnWasDetached(parent, slot_id);
9949
9950 if (HasQuantity())
9951 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9952
9953 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9954 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
9955 }
9956
9957 override string ChangeIntoOnAttach(string slot)
9958 {
9959 int idx;
9960 TStringArray inventory_slots = new TStringArray;
9961 TStringArray attach_types = new TStringArray;
9962
9963 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9964 if (inventory_slots.Count() < 1) //is string
9965 {
9966 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
9967 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
9968 }
9969 else //is array
9970 {
9971 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
9972 }
9973
9974 idx = inventory_slots.Find(slot);
9975 if (idx < 0)
9976 return "";
9977
9978 return attach_types.Get(idx);
9979 }
9980
9981 override string ChangeIntoOnDetach()
9982 {
9983 int idx = -1;
9984 string slot;
9985
9986 TStringArray inventory_slots = new TStringArray;
9987 TStringArray detach_types = new TStringArray;
9988
9989 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9990 if (inventory_slots.Count() < 1) //is string
9991 {
9992 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
9993 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9994 }
9995 else //is array
9996 {
9997 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
9998 if (detach_types.Count() < 1)
9999 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10000 }
10001
10002 for (int i = 0; i < inventory_slots.Count(); i++)
10003 {
10004 slot = inventory_slots.Get(i);
10005 }
10006
10007 if (slot != "")
10008 {
10009 if (detach_types.Count() == 1)
10010 idx = 0;
10011 else
10012 idx = inventory_slots.Find(slot);
10013 }
10014 if (idx < 0)
10015 return "";
10016
10017 return detach_types.Get(idx);
10018 }
10019
10020 void ExplodeAmmo()
10021 {
10022 //timer
10023 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10024
10025 //min/max time
10026 float min_time = 1;
10027 float max_time = 3;
10028 float delay = Math.RandomFloat(min_time, max_time);
10029
10030 explode_timer.Run(delay, this, "DoAmmoExplosion");
10031 }
10032
10033 void DoAmmoExplosion()
10034 {
10035 Magazine magazine = Magazine.Cast(this);
10036 int pop_sounds_count = 6;
10037 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10038
10039 //play sound
10040 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10041 string sound_name = pop_sounds[ sound_idx ];
10042 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
10043
10044 //remove ammo count
10045 magazine.ServerAddAmmoCount(-1);
10046
10047 //if condition then repeat -> ExplodeAmmo
10048 float min_temp_to_explode = 100; //min temperature for item to explode
10049
10050 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10051 {
10052 ExplodeAmmo();
10053 }
10054 }
10055
10056 // -------------------------------------------------------------------------------
10057 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10058 {
10059 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10060
10061 const int CHANCE_DAMAGE_CARGO = 4;
10062 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10063 const int CHANCE_DAMAGE_NOTHING = 2;
10064
10065 if (IsClothing() || IsContainer() || IsItemTent())
10066 {
10067 float dmg = damageResult.GetDamage("","Health") * -0.5;
10068 int chances;
10069 int rnd;
10070
10071 if (GetInventory().GetCargo())
10072 {
10073 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10074 rnd = Math.RandomInt(0,chances);
10075
10076 if (rnd < CHANCE_DAMAGE_CARGO)
10077 {
10078 DamageItemInCargo(dmg);
10079 }
10080 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10081 {
10083 }
10084 }
10085 else
10086 {
10087 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10088 rnd = Math.RandomInt(0,chances);
10089
10090 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10091 {
10093 }
10094 }
10095 }
10096 }
10097
10098 bool DamageItemInCargo(float damage)
10099 {
10100 CargoBase cargo = GetInventory().GetCargo();
10101 if (cargo)
10102 {
10103 int item_count = cargo.GetItemCount();
10104 if (item_count > 0)
10105 {
10106 int random_pick = Math.RandomInt(0, item_count);
10107 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
10108 if (!item.IsExplosive())
10109 {
10110 item.AddHealth("","",damage);
10111 return true;
10112 }
10113 }
10114 }
10115 return false;
10116 }
10117
10118 bool DamageItemAttachments(float damage)
10119 {
10120 GameInventory inventory = GetInventory();
10121 int attachment_count = inventory.AttachmentCount();
10122 if (attachment_count > 0)
10123 {
10124 int random_pick = Math.RandomInt(0, attachment_count);
10125 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
10126 if (!attachment.IsExplosive())
10127 {
10128 attachment.AddHealth("","",damage);
10129 return true;
10130 }
10131 }
10132 return false;
10133 }
10134
10135 override bool IsSplitable()
10136 {
10137 return m_CanThisBeSplit;
10138 }
10139 //----------------
10140 override bool CanBeSplit()
10141 {
10142 if (IsSplitable() && (GetQuantity() > 1))
10143 return GetInventory().CanRemoveEntity();
10144
10145 return false;
10146 }
10147
10148 protected bool ShouldSplitQuantity(float quantity)
10149 {
10150 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10151 if (!IsSplitable())
10152 return false;
10153
10154 // nothing to split?
10155 if (GetQuantity() <= 1)
10156 return false;
10157
10158 // check if we should re-use the item instead of creating a new copy?
10159 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10160 int delta = GetQuantity() - quantity;
10161 if (delta == 0)
10162 return false;
10163
10164 // valid to split
10165 return true;
10166 }
10167
10168 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10169 {
10170 if (g_Game.IsClient())
10171 {
10172 if (ScriptInputUserData.CanStoreInputUserData())
10173 {
10174 ScriptInputUserData ctx = new ScriptInputUserData;
10176 ctx.Write(1);
10177 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10178 ctx.Write(i1);
10179 ctx.Write(destination_entity);
10180 ctx.Write(true);
10181 ctx.Write(slot_id);
10182 ctx.Send();
10183 }
10184 }
10185 else if (!g_Game.IsMultiplayer())
10186 {
10187 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
10188 }
10189 }
10190
10191 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10192 {
10193 float split_quantity_new;
10194 ItemBase new_item;
10195 float quantity = GetQuantity();
10196 float stack_max = GetTargetQuantityMax(slot_id);
10197 InventoryLocation loc = new InventoryLocation;
10198
10199 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10200 {
10201 if (stack_max <= GetQuantity())
10202 split_quantity_new = stack_max;
10203 else
10204 split_quantity_new = GetQuantity();
10205
10206 if (ShouldSplitQuantity(split_quantity_new))
10207 {
10208 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10209 if (new_item)
10210 {
10211 new_item.SetResultOfSplit(true);
10212 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10213 AddQuantity(-split_quantity_new, false, true);
10214 new_item.SetQuantity(split_quantity_new, false, true);
10215 }
10216 }
10217 }
10218 else if (destination_entity && slot_id == -1)
10219 {
10220 if (quantity > stack_max)
10221 split_quantity_new = stack_max;
10222 else
10223 split_quantity_new = quantity;
10224
10225 if (ShouldSplitQuantity(split_quantity_new))
10226 {
10227 GameInventory destinationInventory = destination_entity.GetInventory();
10228 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10229 {
10230 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10231 new_item = ItemBase.Cast(o);
10232 }
10233
10234 if (new_item)
10235 {
10236 new_item.SetResultOfSplit(true);
10237 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10238 AddQuantity(-split_quantity_new, false, true);
10239 new_item.SetQuantity(split_quantity_new, false, true);
10240 }
10241 }
10242 }
10243 else
10244 {
10245 if (stack_max != 0)
10246 {
10247 if (stack_max < GetQuantity())
10248 {
10249 split_quantity_new = GetQuantity() - stack_max;
10250 }
10251
10252 if (split_quantity_new == 0)
10253 {
10254 if (!g_Game.IsMultiplayer())
10255 player.PhysicalPredictiveDropItem(this);
10256 else
10257 player.ServerDropEntity(this);
10258 return;
10259 }
10260
10261 if (ShouldSplitQuantity(split_quantity_new))
10262 {
10263 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10264
10265 if (new_item)
10266 {
10267 new_item.SetResultOfSplit(true);
10268 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10269 SetQuantity(split_quantity_new, false, true);
10270 new_item.SetQuantity(stack_max, false, true);
10271 new_item.PlaceOnSurface();
10272 }
10273 }
10274 }
10275 }
10276 }
10277
10278 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10279 {
10280 float split_quantity_new;
10281 ItemBase new_item;
10282 float quantity = GetQuantity();
10283 float stack_max = GetTargetQuantityMax(slot_id);
10284 InventoryLocation loc = new InventoryLocation;
10285
10286 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10287 {
10288 if (stack_max <= GetQuantity())
10289 split_quantity_new = stack_max;
10290 else
10291 split_quantity_new = GetQuantity();
10292
10293 if (ShouldSplitQuantity(split_quantity_new))
10294 {
10295 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10296 if (new_item)
10297 {
10298 new_item.SetResultOfSplit(true);
10299 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10300 AddQuantity(-split_quantity_new, false, true);
10301 new_item.SetQuantity(split_quantity_new, false, true);
10302 }
10303 }
10304 }
10305 else if (destination_entity && slot_id == -1)
10306 {
10307 if (quantity > stack_max)
10308 split_quantity_new = stack_max;
10309 else
10310 split_quantity_new = quantity;
10311
10312 if (ShouldSplitQuantity(split_quantity_new))
10313 {
10314 GameInventory destinationInventory = destination_entity.GetInventory();
10315 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10316 {
10317 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10318 new_item = ItemBase.Cast(o);
10319 }
10320
10321 if (new_item)
10322 {
10323 new_item.SetResultOfSplit(true);
10324 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10325 AddQuantity(-split_quantity_new, false, true);
10326 new_item.SetQuantity(split_quantity_new, false, true);
10327 }
10328 }
10329 }
10330 else
10331 {
10332 if (stack_max != 0)
10333 {
10334 if (stack_max < GetQuantity())
10335 {
10336 split_quantity_new = GetQuantity() - stack_max;
10337 }
10338
10339 if (ShouldSplitQuantity(split_quantity_new))
10340 {
10341 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10342
10343 if (new_item)
10344 {
10345 new_item.SetResultOfSplit(true);
10346 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10347 SetQuantity(split_quantity_new, false, true);
10348 new_item.SetQuantity(stack_max, false, true);
10349 new_item.PlaceOnSurface();
10350 }
10351 }
10352 }
10353 }
10354 }
10355
10356 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10357 {
10358 if (g_Game.IsClient())
10359 {
10360 if (ScriptInputUserData.CanStoreInputUserData())
10361 {
10362 ScriptInputUserData ctx = new ScriptInputUserData;
10364 ctx.Write(4);
10365 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10366 ctx.Write(thiz);
10367 dst.WriteToContext(ctx);
10368 ctx.Send();
10369 }
10370 }
10371 else if (!g_Game.IsMultiplayer())
10372 {
10374 }
10375 }
10376
10377 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10378 {
10379 if (g_Game.IsClient())
10380 {
10381 if (ScriptInputUserData.CanStoreInputUserData())
10382 {
10383 ScriptInputUserData ctx = new ScriptInputUserData;
10385 ctx.Write(2);
10386 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10387 ctx.Write(dummy);
10388 ctx.Write(destination_entity);
10389 ctx.Write(true);
10390 ctx.Write(idx);
10391 ctx.Write(row);
10392 ctx.Write(col);
10393 ctx.Send();
10394 }
10395 }
10396 else if (!g_Game.IsMultiplayer())
10397 {
10398 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10399 }
10400 }
10401
10402 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10403 {
10405 }
10406
10407 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10408 {
10409 float quantity = GetQuantity();
10410 float split_quantity_new;
10411 ItemBase new_item;
10412 if (dst.IsValid())
10413 {
10414 int slot_id = dst.GetSlot();
10415 float stack_max = GetTargetQuantityMax(slot_id);
10416
10417 if (quantity > stack_max)
10418 split_quantity_new = stack_max;
10419 else
10420 split_quantity_new = quantity;
10421
10422 if (ShouldSplitQuantity(split_quantity_new))
10423 {
10424 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10425
10426 if (new_item)
10427 {
10428 new_item.SetResultOfSplit(true);
10429 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10430 AddQuantity(-split_quantity_new, false, true);
10431 new_item.SetQuantity(split_quantity_new, false, true);
10432 }
10433
10434 return new_item;
10435 }
10436 }
10437
10438 return null;
10439 }
10440
10441 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10442 {
10443 float quantity = GetQuantity();
10444 float split_quantity_new;
10445 ItemBase new_item;
10446 if (destination_entity)
10447 {
10448 float stackable = GetTargetQuantityMax();
10449 if (quantity > stackable)
10450 split_quantity_new = stackable;
10451 else
10452 split_quantity_new = quantity;
10453
10454 if (ShouldSplitQuantity(split_quantity_new))
10455 {
10456 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10457 if (new_item)
10458 {
10459 new_item.SetResultOfSplit(true);
10460 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10461 AddQuantity(-split_quantity_new, false, true);
10462 new_item.SetQuantity(split_quantity_new, false, true);
10463 }
10464 }
10465 }
10466 }
10467
10468 void SplitIntoStackMaxHandsClient(PlayerBase player)
10469 {
10470 if (g_Game.IsClient())
10471 {
10472 if (ScriptInputUserData.CanStoreInputUserData())
10473 {
10474 ScriptInputUserData ctx = new ScriptInputUserData;
10476 ctx.Write(3);
10477 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10478 ctx.Write(i1);
10479 ItemBase destination_entity = this;
10480 ctx.Write(destination_entity);
10481 ctx.Write(true);
10482 ctx.Write(0);
10483 ctx.Send();
10484 }
10485 }
10486 else if (!g_Game.IsMultiplayer())
10487 {
10488 SplitIntoStackMaxHands(player);
10489 }
10490 }
10491
10492 void SplitIntoStackMaxHands(PlayerBase player)
10493 {
10494 float quantity = GetQuantity();
10495 float split_quantity_new;
10496 ref ItemBase new_item;
10497 if (player)
10498 {
10499 float stackable = GetTargetQuantityMax();
10500 if (quantity > stackable)
10501 split_quantity_new = stackable;
10502 else
10503 split_quantity_new = quantity;
10504
10505 if (ShouldSplitQuantity(split_quantity_new))
10506 {
10507 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10508 new_item = ItemBase.Cast(in_hands);
10509 if (new_item)
10510 {
10511 new_item.SetResultOfSplit(true);
10512 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10513 AddQuantity(-split_quantity_new, false, true);
10514 new_item.SetQuantity(split_quantity_new, false, true);
10515 }
10516 }
10517 }
10518 }
10519
10520 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10521 {
10522 float quantity = GetQuantity();
10523 float split_quantity_new = Math.Floor(quantity * 0.5);
10524
10525 if (!ShouldSplitQuantity(split_quantity_new))
10526 return;
10527
10528 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10529
10530 if (new_item)
10531 {
10532 if (new_item.GetQuantityMax() < split_quantity_new)
10533 {
10534 split_quantity_new = new_item.GetQuantityMax();
10535 }
10536
10537 new_item.SetResultOfSplit(true);
10538 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10539
10540 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10541 {
10542 AddQuantity(-1, false, true);
10543 new_item.SetQuantity(1, false, true);
10544 }
10545 else
10546 {
10547 AddQuantity(-split_quantity_new, false, true);
10548 new_item.SetQuantity(split_quantity_new, false, true);
10549 }
10550 }
10551 }
10552
10553 void SplitItem(PlayerBase player)
10554 {
10555 float quantity = GetQuantity();
10556 float split_quantity_new = Math.Floor(quantity / 2);
10557
10558 if (!ShouldSplitQuantity(split_quantity_new))
10559 return;
10560
10561 InventoryLocation invloc = new InventoryLocation;
10562 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10563
10564 ItemBase new_item;
10565 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10566
10567 if (new_item)
10568 {
10569 if (new_item.GetQuantityMax() < split_quantity_new)
10570 {
10571 split_quantity_new = new_item.GetQuantityMax();
10572 }
10573 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10574 {
10575 AddQuantity(-1, false, true);
10576 new_item.SetQuantity(1, false, true);
10577 }
10578 else if (split_quantity_new > 1)
10579 {
10580 AddQuantity(-split_quantity_new, false, true);
10581 new_item.SetQuantity(split_quantity_new, false, true);
10582 }
10583 }
10584 }
10585
10587 void OnQuantityChanged(float delta)
10588 {
10589 SetWeightDirty();
10590 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10591
10592 if (parent)
10593 parent.OnAttachmentQuantityChangedEx(this, delta);
10594
10595 if (IsLiquidContainer())
10596 {
10597 if (GetQuantityNormalized() <= 0.0)
10598 {
10600 }
10601 else if (GetLiquidType() == LIQUID_NONE)
10602 {
10603 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10605 }
10606 }
10607 }
10608
10611 {
10612 // insert code here
10613 }
10614
10616 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10617 {
10619 }
10620
10621 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10622 {
10623 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10624
10625 if (g_Game.IsServer())
10626 {
10627 if (newLevel == GameConstants.STATE_RUINED)
10628 {
10630 EntityAI parent = GetHierarchyParent();
10631 if (parent && parent.IsFireplace())
10632 {
10633 CargoBase cargo = GetInventory().GetCargo();
10634 if (cargo)
10635 {
10636 for (int i = 0; i < cargo.GetItemCount(); ++i)
10637 {
10638 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10639 }
10640 }
10641 }
10642 }
10643
10644 if (IsResultOfSplit())
10645 {
10646 // reset the splitting result flag, return to normal item behavior
10647 SetResultOfSplit(false);
10648 return;
10649 }
10650
10651 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10652 {
10653 SetCleanness(0);//unclean the item upon damage dealt
10654 }
10655 }
10656 }
10657
10658 // just the split? TODO: verify
10659 override void OnRightClick()
10660 {
10661 super.OnRightClick();
10662
10663 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
10664 {
10665 if (g_Game.IsClient())
10666 {
10667 if (ScriptInputUserData.CanStoreInputUserData())
10668 {
10669 EntityAI root = GetHierarchyRoot();
10670 Man playerOwner = GetHierarchyRootPlayer();
10671 InventoryLocation dst = new InventoryLocation;
10672
10673 // 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
10674 if (!playerOwner && root && root == this)
10675 {
10677 }
10678 else
10679 {
10680 // 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
10681 GetInventory().GetCurrentInventoryLocation(dst);
10682 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10683 {
10684 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10685 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10686 {
10688 }
10689 else
10690 {
10691 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10692 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10693 this shouldnt cause issues within this scope*/
10694 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10695 {
10697 }
10698 else
10699 {
10700 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10701 }
10702 }
10703 }
10704 }
10705
10706 ScriptInputUserData ctx = new ScriptInputUserData;
10708 ctx.Write(4);
10709 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10710 ctx.Write(thiz);
10711 dst.WriteToContext(ctx);
10712 ctx.Write(true); // dummy
10713 ctx.Send();
10714 }
10715 }
10716 else if (!g_Game.IsMultiplayer())
10717 {
10718 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
10719 }
10720 }
10721 }
10722
10723 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10724 {
10725 if (root)
10726 {
10727 vector m4[4];
10728 root.GetTransform(m4);
10729 dst.SetGround(this, m4);
10730 }
10731 else
10732 {
10733 GetInventory().GetCurrentInventoryLocation(dst);
10734 }
10735 }
10736
10737 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10738 {
10739 //TODO: delete check zero quantity check after fix double posts hands fsm events
10740 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10741 return false;
10742
10743 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10744 return false;
10745
10746 //can_this_be_combined = ConfigGetBool("canBeSplit");
10748 return false;
10749
10750
10751 Magazine mag = Magazine.Cast(this);
10752 if (mag)
10753 {
10754 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10755 return false;
10756
10757 if (stack_max_limit)
10758 {
10759 Magazine other_mag = Magazine.Cast(other_item);
10760 if (other_item)
10761 {
10762 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10763 return false;
10764 }
10765
10766 }
10767 }
10768 else
10769 {
10770 //TODO: delete check zero quantity check after fix double posts hands fsm events
10771 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10772 return false;
10773
10774 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10775 return false;
10776 }
10777
10778 PlayerBase player = null;
10779 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10780 {
10781 if (player.GetInventory().HasAttachment(this))
10782 return false;
10783
10784 if (player.IsItemsToDelete())
10785 return false;
10786 }
10787
10788 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10789 return false;
10790
10791 int slotID;
10792 string slotName;
10793 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10794 return false;
10795
10796 return true;
10797 }
10798
10799 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10800 {
10801 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10802 }
10803
10804 bool IsResultOfSplit()
10805 {
10806 return m_IsResultOfSplit;
10807 }
10808
10809 void SetResultOfSplit(bool value)
10810 {
10811 m_IsResultOfSplit = value;
10812 }
10813
10814 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
10815 {
10816 return ComputeQuantityUsedEx(other_item, use_stack_max);
10817 }
10818
10819 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
10820 {
10821 float other_item_quantity = other_item.GetQuantity();
10822 float this_free_space;
10823
10824 float stack_max = GetQuantityMax();
10825
10826 this_free_space = stack_max - GetQuantity();
10827
10828 if (other_item_quantity > this_free_space)
10829 {
10830 return this_free_space;
10831 }
10832 else
10833 {
10834 return other_item_quantity;
10835 }
10836 }
10837
10838 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
10839 {
10840 CombineItems(ItemBase.Cast(entity2),use_stack_max);
10841 }
10842
10843 void CombineItems(ItemBase other_item, bool use_stack_max = true)
10844 {
10845 if (!CanBeCombined(other_item, false))
10846 return;
10847
10848 if (!IsMagazine() && other_item)
10849 {
10850 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
10851 if (quantity_used != 0)
10852 {
10853 float hp1 = GetHealth01("","");
10854 float hp2 = other_item.GetHealth01("","");
10855 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
10856 hpResult = hpResult / (GetQuantity() + quantity_used);
10857
10858 hpResult *= GetMaxHealth();
10859 Math.Round(hpResult);
10860 SetHealth("", "Health", hpResult);
10861
10862 AddQuantity(quantity_used);
10863 other_item.AddQuantity(-quantity_used);
10864 }
10865 }
10866 OnCombine(other_item);
10867 }
10868
10869 void OnCombine(ItemBase other_item)
10870 {
10871 #ifdef SERVER
10872 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
10873 GetHierarchyParent().IncreaseLifetimeUp();
10874 #endif
10875 };
10876
10877 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
10878 {
10879 PlayerBase p = PlayerBase.Cast(player);
10880
10881 array<int> recipesIds = p.m_Recipes;
10882 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10883 if (moduleRecipesManager)
10884 {
10885 EntityAI itemInHands = player.GetEntityInHands();
10886 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
10887 }
10888
10889 for (int i = 0;i < recipesIds.Count(); i++)
10890 {
10891 int key = recipesIds.Get(i);
10892 string recipeName = moduleRecipesManager.GetRecipeName(key);
10893 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
10894 }
10895 }
10896
10897 // -------------------------------------------------------------------------
10898 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
10899 {
10900 super.GetDebugActions(outputList);
10901
10902 //quantity
10903 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
10904 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
10905 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
10906 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
10907 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10908
10909 //health
10910 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
10911 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
10912 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
10913 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10914 //temperature
10915 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
10916 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
10917 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
10918 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10919
10920 //wet
10921 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
10922 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
10923 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10924
10925 //liquidtype
10926 if (IsLiquidContainer())
10927 {
10928 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
10929 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
10930 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10931 }
10932
10933 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
10934 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10935
10936 // watch
10937 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
10938 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
10939 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10940
10941 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
10942
10943 InventoryLocation loc = new InventoryLocation();
10944 GetInventory().GetCurrentInventoryLocation(loc);
10945 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
10946 {
10947 if (Gizmo_IsSupported())
10948 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
10949 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
10950 }
10951
10952 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10953 }
10954
10955 // -------------------------------------------------------------------------
10956 // -------------------------------------------------------------------------
10957 // -------------------------------------------------------------------------
10958 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
10959 {
10960 super.OnAction(action_id, player, ctx);
10961
10962 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
10963 {
10964 switch (action_id)
10965 {
10966 case EActions.GIZMO_OBJECT:
10967 if (GetGizmoApi())
10968 GetGizmoApi().SelectObject(this);
10969 return true;
10970 case EActions.GIZMO_PHYSICS:
10971 if (GetGizmoApi())
10972 GetGizmoApi().SelectPhysics(GetPhysics());
10973 return true;
10974 }
10975 }
10976
10977 if (g_Game.IsServer())
10978 {
10979 switch (action_id)
10980 {
10981 case EActions.DELETE:
10982 Delete();
10983 return true;
10984 }
10985 }
10986
10987 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
10988 {
10989 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10990 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
10991 PlayerBase p = PlayerBase.Cast(player);
10992 if (EActions.RECIPES_RANGE_START < 1000)
10993 {
10994 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
10995 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
10996 }
10997 }
10998 #ifndef SERVER
10999 else if (action_id == EActions.WATCH_PLAYER)
11000 {
11001 PluginDeveloper.SetDeveloperItemClientEx(player);
11002 }
11003 #endif
11004 if (g_Game.IsServer())
11005 {
11006 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11007 {
11008 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11009 OnDebugButtonPressServer(id + 1);
11010 }
11011
11012 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11013 {
11014 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11015 InsertAgent(agent_id,100);
11016 }
11017
11018 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11019 {
11020 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11021 RemoveAgent(agent_id2);
11022 }
11023
11024 else if (action_id == EActions.ADD_QUANTITY)
11025 {
11026 if (IsMagazine())
11027 {
11028 Magazine mag = Magazine.Cast(this);
11029 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11030 }
11031 else
11032 {
11033 AddQuantity(GetQuantityMax() * 0.2);
11034 }
11035
11036 if (m_EM)
11037 {
11038 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11039 }
11040 //PrintVariables();
11041 }
11042
11043 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11044 {
11045 if (IsMagazine())
11046 {
11047 Magazine mag2 = Magazine.Cast(this);
11048 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11049 }
11050 else
11051 {
11052 AddQuantity(- GetQuantityMax() * 0.2);
11053 }
11054 if (m_EM)
11055 {
11056 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11057 }
11058 //PrintVariables();
11059 }
11060
11061 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11062 {
11063 SetQuantity(0);
11064
11065 if (m_EM)
11066 {
11067 m_EM.SetEnergy(0);
11068 }
11069 }
11070
11071 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11072 {
11074
11075 if (m_EM)
11076 {
11077 m_EM.SetEnergy(m_EM.GetEnergyMax());
11078 }
11079 }
11080
11081 else if (action_id == EActions.ADD_HEALTH)
11082 {
11083 AddHealth("","",GetMaxHealth("","Health")/5);
11084 }
11085 else if (action_id == EActions.REMOVE_HEALTH)
11086 {
11087 AddHealth("","",-GetMaxHealth("","Health")/5);
11088 }
11089 else if (action_id == EActions.DESTROY_HEALTH)
11090 {
11091 SetHealth01("","",0);
11092 }
11093 else if (action_id == EActions.WATCH_ITEM)
11094 {
11096 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11097 #ifdef DEVELOPER
11098 SetDebugDeveloper_item(this);
11099 #endif
11100 }
11101
11102 else if (action_id == EActions.ADD_TEMPERATURE)
11103 {
11104 AddTemperature(20);
11105 //PrintVariables();
11106 }
11107
11108 else if (action_id == EActions.REMOVE_TEMPERATURE)
11109 {
11110 AddTemperature(-20);
11111 //PrintVariables();
11112 }
11113
11114 else if (action_id == EActions.FLIP_FROZEN)
11115 {
11116 SetFrozen(!GetIsFrozen());
11117 //PrintVariables();
11118 }
11119
11120 else if (action_id == EActions.ADD_WETNESS)
11121 {
11122 AddWet(GetWetMax()/5);
11123 //PrintVariables();
11124 }
11125
11126 else if (action_id == EActions.REMOVE_WETNESS)
11127 {
11128 AddWet(-GetWetMax()/5);
11129 //PrintVariables();
11130 }
11131
11132 else if (action_id == EActions.LIQUIDTYPE_UP)
11133 {
11134 int curr_type = GetLiquidType();
11135 SetLiquidType(curr_type * 2);
11136 //AddWet(1);
11137 //PrintVariables();
11138 }
11139
11140 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11141 {
11142 int curr_type2 = GetLiquidType();
11143 SetLiquidType(curr_type2 / 2);
11144 }
11145
11146 else if (action_id == EActions.MAKE_SPECIAL)
11147 {
11148 auto debugParams = DebugSpawnParams.WithPlayer(player);
11149 OnDebugSpawnEx(debugParams);
11150 }
11151
11152 }
11153
11154
11155 return false;
11156 }
11157
11158 // -------------------------------------------------------------------------
11159
11160
11163 void OnActivatedByTripWire();
11164
11166 void OnActivatedByItem(notnull ItemBase item);
11167
11168 //----------------------------------------------------------------
11169 //returns true if item is able to explode when put in fire
11170 bool CanExplodeInFire()
11171 {
11172 return false;
11173 }
11174
11175 //----------------------------------------------------------------
11176 bool CanEat()
11177 {
11178 return true;
11179 }
11180
11181 //----------------------------------------------------------------
11182 override bool IsIgnoredByConstruction()
11183 {
11184 return true;
11185 }
11186
11187 //----------------------------------------------------------------
11188 //has FoodStages in config?
11189 bool HasFoodStage()
11190 {
11191 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11192 return g_Game.ConfigIsExisting(config_path);
11193 }
11194
11196 FoodStage GetFoodStage()
11197 {
11198 return null;
11199 }
11200
11201 bool CanBeCooked()
11202 {
11203 return false;
11204 }
11205
11206 bool CanBeCookedOnStick()
11207 {
11208 return false;
11209 }
11210
11212 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11214
11215 //----------------------------------------------------------------
11216 bool CanRepair(ItemBase item_repair_kit)
11217 {
11218 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11219 return module_repairing.CanRepair(this, item_repair_kit);
11220 }
11221
11222 //----------------------------------------------------------------
11223 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11224 {
11225 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11226 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11227 }
11228
11229 //----------------------------------------------------------------
11230 int GetItemSize()
11231 {
11232 /*
11233 vector v_size = this.ConfigGetVector("itemSize");
11234 int v_size_x = v_size[0];
11235 int v_size_y = v_size[1];
11236 int size = v_size_x * v_size_y;
11237 return size;
11238 */
11239
11240 return 1;
11241 }
11242
11243 //----------------------------------------------------------------
11244 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11245 bool CanBeMovedOverride()
11246 {
11247 return m_CanBeMovedOverride;
11248 }
11249
11250 //----------------------------------------------------------------
11251 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11252 void SetCanBeMovedOverride(bool setting)
11253 {
11254 m_CanBeMovedOverride = setting;
11255 }
11256
11257 //----------------------------------------------------------------
11265 void MessageToOwnerStatus(string text)
11266 {
11267 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11268
11269 if (player)
11270 {
11271 player.MessageStatus(text);
11272 }
11273 }
11274
11275 //----------------------------------------------------------------
11283 void MessageToOwnerAction(string text)
11284 {
11285 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11286
11287 if (player)
11288 {
11289 player.MessageAction(text);
11290 }
11291 }
11292
11293 //----------------------------------------------------------------
11301 void MessageToOwnerFriendly(string text)
11302 {
11303 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11304
11305 if (player)
11306 {
11307 player.MessageFriendly(text);
11308 }
11309 }
11310
11311 //----------------------------------------------------------------
11319 void MessageToOwnerImportant(string text)
11320 {
11321 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11322
11323 if (player)
11324 {
11325 player.MessageImportant(text);
11326 }
11327 }
11328
11329 override bool IsItemBase()
11330 {
11331 return true;
11332 }
11333
11334 // Checks if item is of questioned kind
11335 override bool KindOf(string tag)
11336 {
11337 bool found = false;
11338 string item_name = this.GetType();
11339 ref TStringArray item_tag_array = new TStringArray;
11340 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11341
11342 int array_size = item_tag_array.Count();
11343 for (int i = 0; i < array_size; i++)
11344 {
11345 if (item_tag_array.Get(i) == tag)
11346 {
11347 found = true;
11348 break;
11349 }
11350 }
11351 return found;
11352 }
11353
11354
11355 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11356 {
11357 //Debug.Log("OnRPC called");
11358 super.OnRPC(sender, rpc_type,ctx);
11359
11360 //Play soundset for attachment locking (ActionLockAttachment.c)
11361 switch (rpc_type)
11362 {
11363 #ifndef SERVER
11364 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11365 Param2<bool, string> p = new Param2<bool, string>(false, "");
11366
11367 if (!ctx.Read(p))
11368 return;
11369
11370 bool play = p.param1;
11371 string soundSet = p.param2;
11372
11373 if (play)
11374 {
11375 if (m_LockingSound)
11376 {
11378 {
11379 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11380 }
11381 }
11382 else
11383 {
11384 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11385 }
11386 }
11387 else
11388 {
11389 SEffectManager.DestroyEffect(m_LockingSound);
11390 }
11391
11392 break;
11393 #endif
11394
11395 }
11396
11397 if (GetWrittenNoteData())
11398 {
11399 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11400 }
11401 }
11402
11403 //-----------------------------
11404 // VARIABLE MANIPULATION SYSTEM
11405 //-----------------------------
11406 int NameToID(string name)
11407 {
11408 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11409 return plugin.GetID(name);
11410 }
11411
11412 string IDToName(int id)
11413 {
11414 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11415 return plugin.GetName(id);
11416 }
11417
11419 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11420 {
11421 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11422 //read the flags
11423 int varFlags;
11424 if (!ctx.Read(varFlags))
11425 return;
11426
11427 if (varFlags & ItemVariableFlags.FLOAT)
11428 {
11429 ReadVarsFromCTX(ctx);
11430 }
11431 }
11432
11433 override void SerializeNumericalVars(array<float> floats_out)
11434 {
11435 //some variables handled on EntityAI level already!
11436 super.SerializeNumericalVars(floats_out);
11437
11438 // the order of serialization must be the same as the order of de-serialization
11439 //--------------------------------------------
11440 if (IsVariableSet(VARIABLE_QUANTITY))
11441 {
11442 floats_out.Insert(m_VarQuantity);
11443 }
11444 //--------------------------------------------
11445 if (IsVariableSet(VARIABLE_WET))
11446 {
11447 floats_out.Insert(m_VarWet);
11448 }
11449 //--------------------------------------------
11450 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11451 {
11452 floats_out.Insert(m_VarLiquidType);
11453 }
11454 //--------------------------------------------
11455 if (IsVariableSet(VARIABLE_COLOR))
11456 {
11457 floats_out.Insert(m_ColorComponentR);
11458 floats_out.Insert(m_ColorComponentG);
11459 floats_out.Insert(m_ColorComponentB);
11460 floats_out.Insert(m_ColorComponentA);
11461 }
11462 //--------------------------------------------
11463 if (IsVariableSet(VARIABLE_CLEANNESS))
11464 {
11465 floats_out.Insert(m_Cleanness);
11466 }
11467 }
11468
11469 override void DeSerializeNumericalVars(array<float> floats)
11470 {
11471 //some variables handled on EntityAI level already!
11472 super.DeSerializeNumericalVars(floats);
11473
11474 // the order of serialization must be the same as the order of de-serialization
11475 int index = 0;
11476 int mask = Math.Round(floats.Get(index));
11477
11478 index++;
11479 //--------------------------------------------
11480 if (mask & VARIABLE_QUANTITY)
11481 {
11482 if (m_IsStoreLoad)
11483 {
11484 SetStoreLoadedQuantity(floats.Get(index));
11485 }
11486 else
11487 {
11488 float quantity = floats.Get(index);
11489 SetQuantity(quantity, true, false, false, false);
11490 }
11491 index++;
11492 }
11493 //--------------------------------------------
11494 if (mask & VARIABLE_WET)
11495 {
11496 float wet = floats.Get(index);
11497 SetWet(wet);
11498 index++;
11499 }
11500 //--------------------------------------------
11501 if (mask & VARIABLE_LIQUIDTYPE)
11502 {
11503 int liquidtype = Math.Round(floats.Get(index));
11504 SetLiquidType(liquidtype);
11505 index++;
11506 }
11507 //--------------------------------------------
11508 if (mask & VARIABLE_COLOR)
11509 {
11510 m_ColorComponentR = Math.Round(floats.Get(index));
11511 index++;
11512 m_ColorComponentG = Math.Round(floats.Get(index));
11513 index++;
11514 m_ColorComponentB = Math.Round(floats.Get(index));
11515 index++;
11516 m_ColorComponentA = Math.Round(floats.Get(index));
11517 index++;
11518 }
11519 //--------------------------------------------
11520 if (mask & VARIABLE_CLEANNESS)
11521 {
11522 int cleanness = Math.Round(floats.Get(index));
11523 SetCleanness(cleanness);
11524 index++;
11525 }
11526 }
11527
11528 override void WriteVarsToCTX(ParamsWriteContext ctx)
11529 {
11530 super.WriteVarsToCTX(ctx);
11531
11532 //--------------------------------------------
11533 if (IsVariableSet(VARIABLE_QUANTITY))
11534 {
11535 ctx.Write(GetQuantity());
11536 }
11537 //--------------------------------------------
11538 if (IsVariableSet(VARIABLE_WET))
11539 {
11540 ctx.Write(GetWet());
11541 }
11542 //--------------------------------------------
11543 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11544 {
11545 ctx.Write(GetLiquidType());
11546 }
11547 //--------------------------------------------
11548 if (IsVariableSet(VARIABLE_COLOR))
11549 {
11550 int r,g,b,a;
11551 GetColor(r,g,b,a);
11552 ctx.Write(r);
11553 ctx.Write(g);
11554 ctx.Write(b);
11555 ctx.Write(a);
11556 }
11557 //--------------------------------------------
11558 if (IsVariableSet(VARIABLE_CLEANNESS))
11559 {
11560 ctx.Write(GetCleanness());
11561 }
11562 }
11563
11564 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11565 {
11566 if (!super.ReadVarsFromCTX(ctx,version))
11567 return false;
11568
11569 int intValue;
11570 float value;
11571
11572 if (version < 140)
11573 {
11574 if (!ctx.Read(intValue))
11575 return false;
11576
11577 m_VariablesMask = intValue;
11578 }
11579
11580 if (m_VariablesMask & VARIABLE_QUANTITY)
11581 {
11582 if (!ctx.Read(value))
11583 return false;
11584
11585 if (IsStoreLoad())
11586 {
11588 }
11589 else
11590 {
11591 SetQuantity(value, true, false, false, false);
11592 }
11593 }
11594 //--------------------------------------------
11595 if (version < 140)
11596 {
11597 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11598 {
11599 if (!ctx.Read(value))
11600 return false;
11601 SetTemperatureDirect(value);
11602 }
11603 }
11604 //--------------------------------------------
11605 if (m_VariablesMask & VARIABLE_WET)
11606 {
11607 if (!ctx.Read(value))
11608 return false;
11609 SetWet(value);
11610 }
11611 //--------------------------------------------
11612 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11613 {
11614 if (!ctx.Read(intValue))
11615 return false;
11616 SetLiquidType(intValue);
11617 }
11618 //--------------------------------------------
11619 if (m_VariablesMask & VARIABLE_COLOR)
11620 {
11621 int r,g,b,a;
11622 if (!ctx.Read(r))
11623 return false;
11624 if (!ctx.Read(g))
11625 return false;
11626 if (!ctx.Read(b))
11627 return false;
11628 if (!ctx.Read(a))
11629 return false;
11630
11631 SetColor(r,g,b,a);
11632 }
11633 //--------------------------------------------
11634 if (m_VariablesMask & VARIABLE_CLEANNESS)
11635 {
11636 if (!ctx.Read(intValue))
11637 return false;
11638 SetCleanness(intValue);
11639 }
11640 //--------------------------------------------
11641 if (version >= 138 && version < 140)
11642 {
11643 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11644 {
11645 if (!ctx.Read(intValue))
11646 return false;
11647 SetFrozen(intValue);
11648 }
11649 }
11650
11651 return true;
11652 }
11653
11654 //----------------------------------------------------------------
11655 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11656 {
11657 m_IsStoreLoad = true;
11659 {
11660 m_FixDamageSystemInit = true;
11661 }
11662
11663 if (!super.OnStoreLoad(ctx, version))
11664 {
11665 m_IsStoreLoad = false;
11666 return false;
11667 }
11668
11669 if (version >= 114)
11670 {
11671 bool hasQuickBarIndexSaved;
11672
11673 if (!ctx.Read(hasQuickBarIndexSaved))
11674 {
11675 m_IsStoreLoad = false;
11676 return false;
11677 }
11678
11679 if (hasQuickBarIndexSaved)
11680 {
11681 int itmQBIndex;
11682
11683 //Load quickbar item bind
11684 if (!ctx.Read(itmQBIndex))
11685 {
11686 m_IsStoreLoad = false;
11687 return false;
11688 }
11689
11690 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11691 if (itmQBIndex != -1 && parentPlayer)
11692 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11693 }
11694 }
11695 else
11696 {
11697 // Backup of how it used to be
11698 PlayerBase player;
11699 int itemQBIndex;
11700 if (version == int.MAX)
11701 {
11702 if (!ctx.Read(itemQBIndex))
11703 {
11704 m_IsStoreLoad = false;
11705 return false;
11706 }
11707 }
11708 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11709 {
11710 //Load quickbar item bind
11711 if (!ctx.Read(itemQBIndex))
11712 {
11713 m_IsStoreLoad = false;
11714 return false;
11715 }
11716 if (itemQBIndex != -1 && player)
11717 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11718 }
11719 }
11720
11721 if (version < 140)
11722 {
11723 // variable management system
11724 if (!LoadVariables(ctx, version))
11725 {
11726 m_IsStoreLoad = false;
11727 return false;
11728 }
11729 }
11730
11731 //agent trasmission system
11732 if (!LoadAgents(ctx, version))
11733 {
11734 m_IsStoreLoad = false;
11735 return false;
11736 }
11737 if (version >= 132)
11738 {
11739 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11740 if (raib)
11741 {
11742 if (!raib.OnStoreLoad(ctx,version))
11743 {
11744 m_IsStoreLoad = false;
11745 return false;
11746 }
11747 }
11748 }
11749
11750 m_IsStoreLoad = false;
11751 return true;
11752 }
11753
11754 //----------------------------------------------------------------
11755
11756 override void OnStoreSave(ParamsWriteContext ctx)
11757 {
11758 super.OnStoreSave(ctx);
11759
11760 PlayerBase player;
11761 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11762 {
11763 ctx.Write(true); // Keep track of if we should actually read this in or not
11764 //Save quickbar item bind
11765 int itemQBIndex = -1;
11766 itemQBIndex = player.FindQuickBarEntityIndex(this);
11767 ctx.Write(itemQBIndex);
11768 }
11769 else
11770 {
11771 ctx.Write(false); // Keep track of if we should actually read this in or not
11772 }
11773
11774 SaveAgents(ctx);//agent trasmission system
11775
11776 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11777 if (raib)
11778 {
11779 raib.OnStoreSave(ctx);
11780 }
11781 }
11782 //----------------------------------------------------------------
11783
11784 override void AfterStoreLoad()
11785 {
11786 super.AfterStoreLoad();
11787
11789 {
11791 }
11792
11793 if (GetStoreLoadedQuantity() != float.LOWEST)
11794 {
11796 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
11797 }
11798 }
11799
11800 override void EEOnAfterLoad()
11801 {
11802 super.EEOnAfterLoad();
11803
11805 {
11806 m_FixDamageSystemInit = false;
11807 }
11808
11811 }
11812
11813 bool CanBeDisinfected()
11814 {
11815 return false;
11816 }
11817
11818
11819 //----------------------------------------------------------------
11820 override void OnVariablesSynchronized()
11821 {
11822 if (m_Initialized)
11823 {
11824 #ifdef PLATFORM_CONSOLE
11825 //bruteforce it is
11826 if (IsSplitable())
11827 {
11828 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
11829 if (menu)
11830 {
11831 menu.Refresh();
11832 }
11833 }
11834 #endif
11835 }
11836
11838 {
11839 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
11840 m_WantPlayImpactSound = false;
11841 }
11842
11844 {
11845 SetWeightDirty();
11847 }
11848 if (m_VarWet != m_VarWetPrev)
11849 {
11852 }
11853
11854 if (m_SoundSyncPlay != 0)
11855 {
11858
11859 m_SoundSyncPlay = 0;
11860 m_SoundSyncSlotID = -1;
11861 }
11862 if (m_SoundSyncStop != 0)
11863 {
11865 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
11866 m_SoundSyncStop = 0;
11867 }
11868
11869 super.OnVariablesSynchronized();
11870 }
11871
11872 //------------------------- Quantity
11873 //----------------------------------------------------------------
11875 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
11876 {
11877 if (!IsServerCheck(allow_client))
11878 return false;
11879
11880 if (!HasQuantity())
11881 return false;
11882
11883 float min = GetQuantityMin();
11884 float max = GetQuantityMax();
11885
11886 if (value <= (min + 0.001))
11887 value = min;
11888
11889 if (value == min)
11890 {
11891 if (destroy_config)
11892 {
11893 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
11894 if (dstr)
11895 {
11896 m_VarQuantity = Math.Clamp(value, min, max);
11897 this.Delete();
11898 return true;
11899 }
11900 }
11901 else if (destroy_forced)
11902 {
11903 m_VarQuantity = Math.Clamp(value, min, max);
11904 this.Delete();
11905 return true;
11906 }
11907 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
11908 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
11909 }
11910
11911 float delta = m_VarQuantity;
11912 m_VarQuantity = Math.Clamp(value, min, max);
11913
11914 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
11915 {
11916 EntityAI parent = GetHierarchyRoot();
11917 InventoryLocation iLoc = new InventoryLocation();
11918 GetInventory().GetCurrentInventoryLocation(iLoc);
11919 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
11920 {
11921 int iLocSlot = iLoc.GetSlot();
11922 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
11923 {
11924 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
11925 }
11926 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
11927 {
11928 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
11929 }
11930 }
11931 }
11932
11933 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
11934 {
11935 delta = m_VarQuantity - delta;
11936
11937 if (delta)
11938 OnQuantityChanged(delta);
11939 }
11940
11941 SetVariableMask(VARIABLE_QUANTITY);
11942
11943 return false;
11944 }
11945
11946 //----------------------------------------------------------------
11948 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
11949 {
11950 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
11951 }
11952 //----------------------------------------------------------------
11953 void SetQuantityMax()
11954 {
11955 float max = GetQuantityMax();
11956 SetQuantity(max);
11957 }
11958
11959 override void SetQuantityToMinimum()
11960 {
11961 float min = GetQuantityMin();
11962 SetQuantity(min);
11963 }
11964 //----------------------------------------------------------------
11966 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
11967 {
11968 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
11969 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
11970 SetQuantity(result, destroy_config, destroy_forced);
11971 }
11972
11973 //----------------------------------------------------------------
11975 override float GetQuantityNormalized()
11976 {
11977 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
11978 }
11979
11981 {
11982 return GetQuantityNormalized();
11983 }
11984
11985 /*void SetAmmoNormalized(float value)
11986 {
11987 float value_clamped = Math.Clamp(value, 0, 1);
11988 Magazine this_mag = Magazine.Cast(this);
11989 int max_rounds = this_mag.GetAmmoMax();
11990 int result = value * max_rounds;//can the rounded if higher precision is required
11991 this_mag.SetAmmoCount(result);
11992 }*/
11993 //----------------------------------------------------------------
11994 override int GetQuantityMax()
11995 {
11996 int slot = -1;
11997 GameInventory inventory = GetInventory();
11998 if (inventory)
11999 {
12000 InventoryLocation il = new InventoryLocation;
12001 inventory.GetCurrentInventoryLocation(il);
12002 slot = il.GetSlot();
12003 }
12004
12005 return GetTargetQuantityMax(slot);
12006 }
12007
12008 override int GetTargetQuantityMax(int attSlotID = -1)
12009 {
12010 float quantity_max = 0;
12011
12012 if (IsSplitable()) //only stackable/splitable items can check for stack size
12013 {
12014 if (attSlotID != -1)
12015 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12016
12017 if (quantity_max <= 0)
12018 quantity_max = m_VarStackMax;
12019 }
12020
12021 if (quantity_max <= 0)
12022 quantity_max = m_VarQuantityMax;
12023
12024 return quantity_max;
12025 }
12026 //----------------------------------------------------------------
12027 override int GetQuantityMin()
12028 {
12029 return m_VarQuantityMin;
12030 }
12031 //----------------------------------------------------------------
12032 int GetQuantityInit()
12033 {
12034 return m_VarQuantityInit;
12035 }
12036
12037 //----------------------------------------------------------------
12038 override bool HasQuantity()
12039 {
12040 return !(GetQuantityMax() - GetQuantityMin() == 0);
12041 }
12042
12043 override float GetQuantity()
12044 {
12045 return m_VarQuantity;
12046 }
12047
12048 bool IsFullQuantity()
12049 {
12050 return GetQuantity() >= GetQuantityMax();
12051 }
12052
12053 //Calculates weight of single item without attachments and cargo
12054 override float GetSingleInventoryItemWeightEx()
12055 {
12056 //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
12057 float weightEx = GetWeightEx();//overall weight of the item
12058 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12059 return weightEx - special;
12060 }
12061
12062 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12064 {
12066 }
12067
12068 override protected float GetWeightSpecialized(bool forceRecalc = false)
12069 {
12070 if (IsSplitable()) //quantity determines size of the stack
12071 {
12072 #ifdef DEVELOPER
12073 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12074 {
12075 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12076 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12077 }
12078 #endif
12079
12080 return GetQuantity() * GetConfigWeightModified();
12081 }
12082 else if (HasEnergyManager())// items with energy manager
12083 {
12084 #ifdef DEVELOPER
12085 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12086 {
12087 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12088 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12089 }
12090 #endif
12091 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12092 }
12093 else//everything else
12094 {
12095 #ifdef DEVELOPER
12096 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12097 {
12098 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12099 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12100 }
12101 #endif
12102 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12103 }
12104 }
12105
12107 int GetNumberOfItems()
12108 {
12109 int item_count = 0;
12110 ItemBase item;
12111
12112 GameInventory inventory = GetInventory();
12113 CargoBase cargo = inventory.GetCargo();
12114 if (cargo != NULL)
12115 {
12116 item_count = cargo.GetItemCount();
12117 }
12118
12119 int nAttachments = inventory.AttachmentCount();
12120 for (int i = 0; i < nAttachments; ++i)
12121 {
12122 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
12123 if (item)
12124 item_count += item.GetNumberOfItems();
12125 }
12126 return item_count;
12127 }
12128
12130 float GetUnitWeight(bool include_wetness = true)
12131 {
12132 float weight = 0;
12133 float wetness = 1;
12134 if (include_wetness)
12135 wetness += GetWet();
12136 if (IsSplitable()) //quantity determines size of the stack
12137 {
12138 weight = wetness * m_ConfigWeight;
12139 }
12140 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12141 {
12142 weight = 1;
12143 }
12144 return weight;
12145 }
12146
12147 //-----------------------------------------------------------------
12148
12149 override void ClearInventory()
12150 {
12151 GameInventory inventory = GetInventory();
12152 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
12153 {
12154 array<EntityAI> items = new array<EntityAI>;
12155 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
12156 for (int i = 0; i < items.Count(); ++i)
12157 {
12158 ItemBase item = ItemBase.Cast(items.Get(i));
12159 if (item)
12160 {
12161 g_Game.ObjectDelete(item);
12162 }
12163 }
12164 }
12165 }
12166
12167 //------------------------- Energy
12168
12169 //----------------------------------------------------------------
12170 float GetEnergy()
12171 {
12172 float energy = 0;
12173 if (HasEnergyManager())
12174 {
12175 energy = GetCompEM().GetEnergy();
12176 }
12177 return energy;
12178 }
12179
12180
12181 override void OnEnergyConsumed()
12182 {
12183 super.OnEnergyConsumed();
12184
12186 }
12187
12188 override void OnEnergyAdded()
12189 {
12190 super.OnEnergyAdded();
12191
12193 }
12194
12195 // Converts energy (from Energy Manager) to quantity, if enabled.
12197 {
12198 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12199 {
12200 if (HasQuantity())
12201 {
12202 float energy_0to1 = GetCompEM().GetEnergy0To1();
12203 SetQuantityNormalized(energy_0to1);
12204 }
12205 }
12206 }
12207
12208 //----------------------------------------------------------------
12209 float GetHeatIsolationInit()
12210 {
12211 return ConfigGetFloat("heatIsolation");
12212 }
12213
12214 float GetHeatIsolation()
12215 {
12216 return m_HeatIsolation;
12217 }
12218
12219 float GetDryingIncrement(string pIncrementName)
12220 {
12221 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12222 if (g_Game.ConfigIsExisting(paramPath))
12223 return g_Game.ConfigGetFloat(paramPath);
12224
12225 return 0.0;
12226 }
12227
12228 float GetSoakingIncrement(string pIncrementName)
12229 {
12230 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12231 if (g_Game.ConfigIsExisting(paramPath))
12232 return g_Game.ConfigGetFloat(paramPath);
12233
12234 return 0.0;
12235 }
12236 //----------------------------------------------------------------
12237 override void SetWet(float value, bool allow_client = false)
12238 {
12239 if (!IsServerCheck(allow_client))
12240 return;
12241
12242 float min = GetWetMin();
12243 float max = GetWetMax();
12244
12245 float previousValue = m_VarWet;
12246
12247 m_VarWet = Math.Clamp(value, min, max);
12248
12249 if (previousValue != m_VarWet)
12250 {
12251 SetVariableMask(VARIABLE_WET);
12252 OnWetChanged(m_VarWet, previousValue);
12253 }
12254 }
12255 //----------------------------------------------------------------
12256 override void AddWet(float value)
12257 {
12258 SetWet(GetWet() + value);
12259 }
12260 //----------------------------------------------------------------
12261 override void SetWetMax()
12262 {
12264 }
12265 //----------------------------------------------------------------
12266 override float GetWet()
12267 {
12268 return m_VarWet;
12269 }
12270 //----------------------------------------------------------------
12271 override float GetWetMax()
12272 {
12273 return m_VarWetMax;
12274 }
12275 //----------------------------------------------------------------
12276 override float GetWetMin()
12277 {
12278 return m_VarWetMin;
12279 }
12280 //----------------------------------------------------------------
12281 override float GetWetInit()
12282 {
12283 return m_VarWetInit;
12284 }
12285 //----------------------------------------------------------------
12286 override void OnWetChanged(float newVal, float oldVal)
12287 {
12288 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12289 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12290 if (newLevel != oldLevel)
12291 {
12292 OnWetLevelChanged(newLevel,oldLevel);
12293 }
12294 }
12295
12296 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12297 {
12298 SetWeightDirty();
12299 }
12300
12301 override EWetnessLevel GetWetLevel()
12302 {
12303 return GetWetLevelInternal(m_VarWet);
12304 }
12305
12306 //----------------------------------------------------------------
12307
12308 override void SetStoreLoad(bool value)
12309 {
12310 m_IsStoreLoad = value;
12311 }
12312
12313 override bool IsStoreLoad()
12314 {
12315 return m_IsStoreLoad;
12316 }
12317
12318 override void SetStoreLoadedQuantity(float value)
12319 {
12320 m_StoreLoadedQuantity = value;
12321 }
12322
12323 override float GetStoreLoadedQuantity()
12324 {
12325 return m_StoreLoadedQuantity;
12326 }
12327
12328 //----------------------------------------------------------------
12329
12330 float GetItemModelLength()
12331 {
12332 if (ConfigIsExisting("itemModelLength"))
12333 {
12334 return ConfigGetFloat("itemModelLength");
12335 }
12336 return 0;
12337 }
12338
12339 float GetItemAttachOffset()
12340 {
12341 if (ConfigIsExisting("itemAttachOffset"))
12342 {
12343 return ConfigGetFloat("itemAttachOffset");
12344 }
12345 return 0;
12346 }
12347
12348 override void SetCleanness(int value, bool allow_client = false)
12349 {
12350 if (!IsServerCheck(allow_client))
12351 return;
12352
12353 int previousValue = m_Cleanness;
12354
12355 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12356
12357 if (previousValue != m_Cleanness)
12358 SetVariableMask(VARIABLE_CLEANNESS);
12359 }
12360
12361 override int GetCleanness()
12362 {
12363 return m_Cleanness;
12364 }
12365
12367 {
12368 return true;
12369 }
12370
12371 //----------------------------------------------------------------
12372 // ATTACHMENT LOCKING
12373 // Getters relevant to generic ActionLockAttachment
12374 int GetLockType()
12375 {
12376 return m_LockType;
12377 }
12378
12379 string GetLockSoundSet()
12380 {
12381 return m_LockSoundSet;
12382 }
12383
12384 //----------------------------------------------------------------
12385 //------------------------- Color
12386 // sets items color variable given color components
12387 override void SetColor(int r, int g, int b, int a)
12388 {
12393 SetVariableMask(VARIABLE_COLOR);
12394 }
12396 override void GetColor(out int r,out int g,out int b,out int a)
12397 {
12402 }
12403
12404 bool IsColorSet()
12405 {
12406 return IsVariableSet(VARIABLE_COLOR);
12407 }
12408
12410 string GetColorString()
12411 {
12412 int r,g,b,a;
12413 GetColor(r,g,b,a);
12414 r = r/255;
12415 g = g/255;
12416 b = b/255;
12417 a = a/255;
12418 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12419 }
12420 //----------------------------------------------------------------
12421 //------------------------- LiquidType
12422
12423 override void SetLiquidType(int value, bool allow_client = false)
12424 {
12425 if (!IsServerCheck(allow_client))
12426 return;
12427
12428 int old = m_VarLiquidType;
12429 m_VarLiquidType = value;
12430 OnLiquidTypeChanged(old,value);
12431 SetVariableMask(VARIABLE_LIQUIDTYPE);
12432 }
12433
12434 int GetLiquidTypeInit()
12435 {
12436 return ConfigGetInt("varLiquidTypeInit");
12437 }
12438
12439 override int GetLiquidType()
12440 {
12441 return m_VarLiquidType;
12442 }
12443
12444 protected void OnLiquidTypeChanged(int oldType, int newType)
12445 {
12446 if (newType == LIQUID_NONE && GetIsFrozen())
12447 SetFrozen(false);
12448 }
12449
12451 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12452 {
12453 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12454 }
12455
12456 // -------------------------------------------------------------------------
12458 void OnInventoryEnter(Man player)
12459 {
12460 PlayerBase nplayer;
12461 if (PlayerBase.CastTo(nplayer, player))
12462 {
12463 m_CanPlayImpactSound = true;
12464 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12465 }
12466 }
12467
12468 // -------------------------------------------------------------------------
12470 void OnInventoryExit(Man player)
12471 {
12472 PlayerBase nplayer;
12473 if (PlayerBase.CastTo(nplayer,player))
12474 {
12475 nplayer.SetEnableQuickBarEntityShortcut(this, false);
12476 }
12477
12478 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12479
12480 if (HasEnergyManager())
12481 {
12482 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12483 }
12484 }
12485
12486 // ADVANCED PLACEMENT EVENTS
12487 override void OnPlacementStarted(Man player)
12488 {
12489 super.OnPlacementStarted(player);
12490
12491 SetTakeable(false);
12492 }
12493
12494 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12495 {
12496 if (m_AdminLog)
12497 {
12498 m_AdminLog.OnPlacementComplete(player, this);
12499 }
12500
12501 super.OnPlacementComplete(player, position, orientation);
12502 }
12503
12504 //-----------------------------
12505 // AGENT SYSTEM
12506 //-----------------------------
12507 //--------------------------------------------------------------------------
12508 bool ContainsAgent(int agent_id)
12509 {
12510 if (agent_id & m_AttachedAgents)
12511 {
12512 return true;
12513 }
12514 else
12515 {
12516 return false;
12517 }
12518 }
12519
12520 //--------------------------------------------------------------------------
12521 override void RemoveAgent(int agent_id)
12522 {
12523 if (ContainsAgent(agent_id))
12524 {
12525 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12526 }
12527 }
12528
12529 //--------------------------------------------------------------------------
12530 override void RemoveAllAgents()
12531 {
12532 m_AttachedAgents = 0;
12533 }
12534 //--------------------------------------------------------------------------
12535 override void RemoveAllAgentsExcept(int agent_to_keep)
12536 {
12537 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12538 }
12539 // -------------------------------------------------------------------------
12540 override void InsertAgent(int agent, float count = 1)
12541 {
12542 if (count < 1)
12543 return;
12544 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12546 }
12547
12549 void TransferAgents(int agents)
12550 {
12552 }
12553
12554 // -------------------------------------------------------------------------
12555 override int GetAgents()
12556 {
12557 return m_AttachedAgents;
12558 }
12559 //----------------------------------------------------------------------
12560
12561 /*int GetContaminationType()
12562 {
12563 int contamination_type;
12564
12565 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12566 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12567 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12568 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12569
12570 Edible_Base edible = Edible_Base.Cast(this);
12571 int agents = GetAgents();
12572 if (edible)
12573 {
12574 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12575 if (profile)
12576 {
12577 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12578 }
12579 }
12580 if (agents & CONTAMINATED_MASK)
12581 {
12582 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12583 }
12584 if (agents & POISONED_MASK)
12585 {
12586 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12587 }
12588 if (agents & NERVE_GAS_MASK)
12589 {
12590 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12591 }
12592 if (agents & DIRTY_MASK)
12593 {
12594 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12595 }
12596
12597 return agents;
12598 }*/
12599
12600 // -------------------------------------------------------------------------
12601 bool LoadAgents(ParamsReadContext ctx, int version)
12602 {
12603 if (!ctx.Read(m_AttachedAgents))
12604 return false;
12605 return true;
12606 }
12607 // -------------------------------------------------------------------------
12609 {
12610
12612 }
12613 // -------------------------------------------------------------------------
12614
12616 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12617 {
12618 super.CheckForRoofLimited(timeTresholdMS);
12619
12620 float time = g_Game.GetTime();
12621 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12622 {
12623 m_PreviousRoofTestTime = time;
12624 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12625 }
12626 }
12627
12628 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12629 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12630 {
12631 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12632 {
12633 return 0;
12634 }
12635
12636 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12637 {
12638 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12639 if (filter)
12640 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12641 else
12642 return 0;//otherwise return 0 when no filter attached
12643 }
12644
12645 string subclassPath, entryName;
12646
12647 switch (type)
12648 {
12649 case DEF_BIOLOGICAL:
12650 entryName = "biological";
12651 break;
12652 case DEF_CHEMICAL:
12653 entryName = "chemical";
12654 break;
12655 default:
12656 entryName = "biological";
12657 break;
12658 }
12659
12660 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12661
12662 return g_Game.ConfigGetFloat(subclassPath + entryName);
12663 }
12664
12665
12666
12668 override void EEOnCECreate()
12669 {
12670 if (!IsMagazine())
12672
12674 }
12675
12676
12677 //-------------------------
12678 // OPEN/CLOSE USER ACTIONS
12679 //-------------------------
12681 void Open();
12682 void Close();
12683 bool IsOpen()
12684 {
12685 return true;
12686 }
12687
12688 override bool CanDisplayCargo()
12689 {
12690 return IsOpen();
12691 }
12692
12693
12694 // ------------------------------------------------------------
12695 // CONDITIONS
12696 // ------------------------------------------------------------
12697 override bool CanPutInCargo(EntityAI parent)
12698 {
12699 if (parent)
12700 {
12701 if (parent.IsInherited(DayZInfected))
12702 return true;
12703
12704 if (!parent.IsRuined())
12705 return true;
12706 }
12707
12708 return true;
12709 }
12710
12711 override bool CanPutAsAttachment(EntityAI parent)
12712 {
12713 if (!super.CanPutAsAttachment(parent))
12714 {
12715 return false;
12716 }
12717
12718 if (!IsRuined() && !parent.IsRuined())
12719 {
12720 return true;
12721 }
12722
12723 return false;
12724 }
12725
12726 override bool CanReceiveItemIntoCargo(EntityAI item)
12727 {
12728 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12729 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12730 // return false;
12731
12732 return super.CanReceiveItemIntoCargo(item);
12733 }
12734
12735 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12736 {
12737 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12738 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12739 // return false;
12740
12741 GameInventory attachmentInv = attachment.GetInventory();
12742 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12743 {
12744 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12745 return false;
12746 }
12747
12748 InventoryLocation loc = new InventoryLocation();
12749 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12750 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12751 return false;
12752
12753 return super.CanReceiveAttachment(attachment, slotId);
12754 }
12755
12756 override bool CanReleaseAttachment(EntityAI attachment)
12757 {
12758 if (!super.CanReleaseAttachment(attachment))
12759 return false;
12760
12761 return GetInventory().AreChildrenAccessible();
12762 }
12763
12764 /*override bool CanLoadAttachment(EntityAI attachment)
12765 {
12766 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12767 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12768 // return false;
12769
12770 GameInventory attachmentInv = attachment.GetInventory();
12771 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12772 {
12773 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12774 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12775
12776 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12777 return false;
12778 }
12779
12780 return super.CanLoadAttachment(attachment);
12781 }*/
12782
12783 // Plays muzzle flash particle effects
12784 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12785 {
12786 int id = muzzle_owner.GetMuzzleID();
12787 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12788
12789 if (WPOF_array)
12790 {
12791 for (int i = 0; i < WPOF_array.Count(); i++)
12792 {
12793 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12794
12795 if (WPOF)
12796 {
12797 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12798 }
12799 }
12800 }
12801 }
12802
12803 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12804 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12805 {
12806 int id = muzzle_owner.GetMuzzleID();
12807 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12808
12809 if (WPOBE_array)
12810 {
12811 for (int i = 0; i < WPOBE_array.Count(); i++)
12812 {
12813 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12814
12815 if (WPOBE)
12816 {
12817 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12818 }
12819 }
12820 }
12821 }
12822
12823 // Plays all weapon overheating particles
12824 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12825 {
12826 int id = muzzle_owner.GetMuzzleID();
12827 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12828
12829 if (WPOOH_array)
12830 {
12831 for (int i = 0; i < WPOOH_array.Count(); i++)
12832 {
12833 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12834
12835 if (WPOOH)
12836 {
12837 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12838 }
12839 }
12840 }
12841 }
12842
12843 // Updates all weapon overheating particles
12844 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12845 {
12846 int id = muzzle_owner.GetMuzzleID();
12847 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12848
12849 if (WPOOH_array)
12850 {
12851 for (int i = 0; i < WPOOH_array.Count(); i++)
12852 {
12853 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12854
12855 if (WPOOH)
12856 {
12857 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12858 }
12859 }
12860 }
12861 }
12862
12863 // Stops overheating particles
12864 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12865 {
12866 int id = muzzle_owner.GetMuzzleID();
12867 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12868
12869 if (WPOOH_array)
12870 {
12871 for (int i = 0; i < WPOOH_array.Count(); i++)
12872 {
12873 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12874
12875 if (WPOOH)
12876 {
12877 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12878 }
12879 }
12880 }
12881 }
12882
12883 //----------------------------------------------------------------
12884 //Item Behaviour - unified approach
12885 override bool IsHeavyBehaviour()
12886 {
12887 if (m_ItemBehaviour == 0)
12888 {
12889 return true;
12890 }
12891
12892 return false;
12893 }
12894
12895 override bool IsOneHandedBehaviour()
12896 {
12897 if (m_ItemBehaviour == 1)
12898 {
12899 return true;
12900 }
12901
12902 return false;
12903 }
12904
12905 override bool IsTwoHandedBehaviour()
12906 {
12907 if (m_ItemBehaviour == 2)
12908 {
12909 return true;
12910 }
12911
12912 return false;
12913 }
12914
12915 bool IsDeployable()
12916 {
12917 return false;
12918 }
12919
12921 float GetDeployTime()
12922 {
12923 return UATimeSpent.DEFAULT_DEPLOY;
12924 }
12925
12926
12927 //----------------------------------------------------------------
12928 // Item Targeting (User Actions)
12929 override void SetTakeable(bool pState)
12930 {
12931 m_IsTakeable = pState;
12932 SetSynchDirty();
12933 }
12934
12935 override bool IsTakeable()
12936 {
12937 return m_IsTakeable;
12938 }
12939
12940 // For cases where we want to show object widget which cant be taken to hands
12942 {
12943 return false;
12944 }
12945
12947 protected void PreLoadSoundAttachmentType()
12948 {
12949 string att_type = "None";
12950
12951 if (ConfigIsExisting("soundAttType"))
12952 {
12953 att_type = ConfigGetString("soundAttType");
12954 }
12955
12956 m_SoundAttType = att_type;
12957 }
12958
12959 override string GetAttachmentSoundType()
12960 {
12961 return m_SoundAttType;
12962 }
12963
12964 //----------------------------------------------------------------
12965 //SOUNDS - ItemSoundHandler
12966 //----------------------------------------------------------------
12967
12968 string GetPlaceSoundset(); // played when deploy starts
12969 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
12970 string GetDeploySoundset(); // played when deploy sucessfully finishes
12971 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
12972 string GetFoldSoundset(); // played when fold sucessfully finishes
12973
12975 {
12976 if (!m_ItemSoundHandler)
12978
12979 return m_ItemSoundHandler;
12980 }
12981
12982 // override to initialize sounds
12983 protected void InitItemSounds()
12984 {
12985 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
12986 return;
12987
12989
12990 if (GetPlaceSoundset() != string.Empty)
12991 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
12992
12993 if (GetDeploySoundset() != string.Empty)
12994 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
12995
12996 SoundParameters params = new SoundParameters();
12997 params.m_Loop = true;
12998 if (GetLoopDeploySoundset() != string.Empty)
12999 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13000 }
13001
13002 // Start sound using ItemSoundHandler
13003 void StartItemSoundServer(int id, int slotId)
13004 {
13005 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
13006 {
13007 m_SoundSyncSlotID = slotId;
13008 m_SoundSyncPlay = id;
13009
13010 SetSynchDirty();
13011
13012 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13013 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
13014 }
13015 }
13016
13017 void StartItemSoundServer(int id)
13018 {
13019 StartItemSoundServer(id, InventorySlots.INVALID);
13020 }
13021
13022 // Stop sound using ItemSoundHandler
13023 void StopItemSoundServer(int id)
13024 {
13025 if (!g_Game.IsServer())
13026 return;
13027
13028 m_SoundSyncStop = id;
13029 SetSynchDirty();
13030
13031 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13032 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
13033 }
13034
13035 protected void ClearStartItemSoundServer()
13036 {
13037 m_SoundSyncPlay = 0;
13038 m_SoundSyncSlotID = InventorySlots.INVALID;
13039 }
13040
13041 protected void ClearStopItemSoundServer()
13042 {
13043 m_SoundSyncStop = 0;
13044 }
13045
13046 void OnApply(PlayerBase player);
13047
13049 {
13050 return 1.0;
13051 };
13052 //returns applicable selection
13053 array<string> GetHeadHidingSelection()
13054 {
13056 }
13057
13059 {
13061 }
13062
13063 WrittenNoteData GetWrittenNoteData() {};
13064
13066 {
13067 SetDynamicPhysicsLifeTime(0.01);
13068 m_ItemBeingDroppedPhys = false;
13069 }
13070
13072 {
13073 array<string> zone_names = new array<string>;
13074 GetDamageZones(zone_names);
13075 for (int i = 0; i < zone_names.Count(); i++)
13076 {
13077 SetHealthMax(zone_names.Get(i),"Health");
13078 }
13079 SetHealthMax("","Health");
13080 }
13081
13083 void SetZoneDamageCEInit()
13084 {
13085 float global_health = GetHealth01("","Health");
13086 array<string> zones = new array<string>;
13087 GetDamageZones(zones);
13088 //set damage of all zones to match global health level
13089 for (int i = 0; i < zones.Count(); i++)
13090 {
13091 SetHealth01(zones.Get(i),"Health",global_health);
13092 }
13093 }
13094
13096 bool IsCoverFaceForShave(string slot_name)
13097 {
13098 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13099 }
13100
13101 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13102 {
13103 if (!hasRootAsPlayer)
13104 {
13105 if (refParentIB)
13106 {
13107 // parent is wet
13108 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13109 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13110 // parent has liquid inside
13111 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13112 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13113 // drying
13114 else if (m_VarWet > m_VarWetMin)
13115 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13116 }
13117 else
13118 {
13119 // drying on ground or inside non-itembase (car, ...)
13120 if (m_VarWet > m_VarWetMin)
13121 AddWet(-1 * delta * GetDryingIncrement("ground"));
13122 }
13123 }
13124 }
13125
13126 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13127 {
13129 {
13130 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13131 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13132 {
13133 float heatPermCoef = 1.0;
13134 EntityAI ent = this;
13135 while (ent)
13136 {
13137 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13138 ent = ent.GetHierarchyParent();
13139 }
13140
13141 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13142 }
13143 }
13144 }
13145
13146 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13147 {
13148 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13149 EntityAI parent = GetHierarchyParent();
13150 if (!parent)
13151 {
13152 hasParent = false;
13153 hasRootAsPlayer = false;
13154 }
13155 else
13156 {
13157 hasParent = true;
13158 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13159 refParentIB = ItemBase.Cast(parent);
13160 }
13161 }
13162
13163 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13164 {
13165 // this is stub, implemented on Edible_Base
13166 }
13167
13168 bool CanDecay()
13169 {
13170 // return true used on selected food clases so they can decay
13171 return false;
13172 }
13173
13174 protected bool CanProcessDecay()
13175 {
13176 // this is stub, implemented on Edible_Base class
13177 // used to determine whether it is still necessary for the food to decay
13178 return false;
13179 }
13180
13181 protected bool CanHaveWetness()
13182 {
13183 // return true used on selected items that have a wetness effect
13184 return false;
13185 }
13186
13188 bool CanBeConsumed(ConsumeConditionData data = null)
13189 {
13190 return !GetIsFrozen() && IsOpen();
13191 }
13192
13193 override void ProcessVariables()
13194 {
13195 bool hasParent = false, hasRootAsPlayer = false;
13196 ItemBase refParentIB;
13197
13198 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13199 bool foodDecay = g_Game.IsFoodDecayEnabled();
13200
13201 if (wwtu || foodDecay)
13202 {
13203 bool processWetness = wwtu && CanHaveWetness();
13204 bool processTemperature = wwtu && CanHaveTemperature();
13205 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13206
13207 if (processWetness || processTemperature || processDecay)
13208 {
13209 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13210
13211 if (processWetness)
13212 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13213
13214 if (processTemperature)
13215 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13216
13217 if (processDecay)
13218 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13219 }
13220 }
13221 }
13222
13225 {
13226 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13227 }
13228
13229 override float GetTemperatureFreezeThreshold()
13230 {
13232 return Liquid.GetFreezeThreshold(GetLiquidType());
13233
13234 return super.GetTemperatureFreezeThreshold();
13235 }
13236
13237 override float GetTemperatureThawThreshold()
13238 {
13240 return Liquid.GetThawThreshold(GetLiquidType());
13241
13242 return super.GetTemperatureThawThreshold();
13243 }
13244
13245 override float GetItemOverheatThreshold()
13246 {
13248 return Liquid.GetBoilThreshold(GetLiquidType());
13249
13250 return super.GetItemOverheatThreshold();
13251 }
13252
13253 override float GetTemperatureFreezeTime()
13254 {
13255 if (HasQuantity())
13256 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13257
13258 return super.GetTemperatureFreezeTime();
13259 }
13260
13261 override float GetTemperatureThawTime()
13262 {
13263 if (HasQuantity())
13264 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13265
13266 return super.GetTemperatureThawTime();
13267 }
13268
13270 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13272 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13273
13274 bool IsCargoException4x3(EntityAI item)
13275 {
13276 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13277 }
13278
13280 {
13281 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13282 }
13283
13285 void AddLightSourceItem(ItemBase lightsource)
13286 {
13287 m_LightSourceItem = lightsource;
13288 }
13289
13291 {
13292 m_LightSourceItem = null;
13293 }
13294
13296 {
13297 return m_LightSourceItem;
13298 }
13299
13301 array<int> GetValidFinishers()
13302 {
13303 return null;
13304 }
13305
13307 bool GetActionWidgetOverride(out typename name)
13308 {
13309 return false;
13310 }
13311
13312 bool PairWithDevice(notnull ItemBase otherDevice)
13313 {
13314 if (g_Game.IsServer())
13315 {
13316 ItemBase explosive = otherDevice;
13318 if (!trg)
13319 {
13320 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13321 explosive = this;
13322 }
13323
13324 explosive.PairRemote(trg);
13325 trg.SetControlledDevice(explosive);
13326
13327 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13328 trg.SetPersistentPairID(persistentID);
13329 explosive.SetPersistentPairID(persistentID);
13330
13331 return true;
13332 }
13333 return false;
13334 }
13335
13337 float GetBaitEffectivity()
13338 {
13339 float ret = 1.0;
13340 if (HasQuantity())
13341 ret *= GetQuantityNormalized();
13342 ret *= GetHealth01();
13343
13344 return ret;
13345 }
13346
13347 #ifdef DEVELOPER
13348 override void SetDebugItem()
13349 {
13350 super.SetDebugItem();
13351 _itemBase = this;
13352 }
13353
13354 override string GetDebugText()
13355 {
13356 string text = super.GetDebugText();
13357
13358 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13359 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13360
13361 return text;
13362 }
13363 #endif
13364
13365 bool CanBeUsedForSuicide()
13366 {
13367 return true;
13368 }
13369
13371 //DEPRECATED BELOW
13373 // Backwards compatibility
13374 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13375 {
13376 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13377 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13378 }
13379
13380 // replaced by ItemSoundHandler
13381 protected EffectSound m_SoundDeployFinish;
13382 protected EffectSound m_SoundPlace;
13383 protected EffectSound m_DeployLoopSoundEx;
13384 protected EffectSound m_SoundDeploy;
13385 bool m_IsPlaceSound;
13386 bool m_IsDeploySound;
13388
13389 string GetDeployFinishSoundset();
13390 void PlayDeploySound();
13391 void PlayDeployFinishSound();
13392 void PlayPlaceSound();
13393 void PlayDeployLoopSoundEx();
13394 void StopDeployLoopSoundEx();
13395 void SoundSynchRemoteReset();
13396 void SoundSynchRemote();
13397 bool UsesGlobalDeploy(){return false;}
13398 bool CanPlayDeployLoopSound(){return false;}
13400 bool IsPlaceSound(){return m_IsPlaceSound;}
13401 bool IsDeploySound(){return m_IsDeploySound;}
13402 void SetIsPlaceSound(bool is_place_sound);
13403 void SetIsDeploySound(bool is_deploy_sound);
13404
13405 [Obsolete("Use ItemSoundHandler instead")]
13407 void PlayAttachSound(string slot_type)
13408 {
13409 if (!g_Game.IsDedicatedServer())
13410 {
13411 if (ConfigIsExisting("attachSoundSet"))
13412 {
13413 string cfg_path = "";
13414 string soundset = "";
13415 string type_name = GetType();
13416
13417 TStringArray cfg_soundset_array = new TStringArray;
13418 TStringArray cfg_slot_array = new TStringArray;
13419 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13420 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13421
13422 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13423 {
13424 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13425 {
13426 if (cfg_slot_array[i] == slot_type)
13427 {
13428 soundset = cfg_soundset_array[i];
13429 break;
13430 }
13431 }
13432 }
13433
13434 if (soundset != "")
13435 {
13436 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13437 sound.SetAutodestroy(true);
13438 }
13439 }
13440 }
13441 }
13442
13443 void PlayDetachSound(string slot_type) {}
13444}
13445
13446EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13447{
13448 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13449 if (entity)
13450 {
13451 bool is_item = entity.IsInherited(ItemBase);
13452 if (is_item && full_quantity)
13453 {
13454 ItemBase item = ItemBase.Cast(entity);
13455 item.SetQuantity(item.GetQuantityInit());
13456 }
13457 }
13458 else
13459 {
13460 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13461 return NULL;
13462 }
13463 return entity;
13464}
13465
13466void SetupSpawnedItem(ItemBase item, float health, float quantity)
13467{
13468 if (item)
13469 {
13470 if (health > 0)
13471 item.SetHealth("", "", health);
13472
13473 if (item.CanHaveTemperature())
13474 {
13475 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13476 if (item.CanFreeze())
13477 item.SetFrozen(false);
13478 }
13479
13480 if (item.HasEnergyManager())
13481 {
13482 if (quantity >= 0)
13483 {
13484 item.GetCompEM().SetEnergy0To1(quantity);
13485 }
13486 else
13487 {
13488 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13489 }
13490 }
13491 else if (item.IsMagazine())
13492 {
13493 Magazine mag = Magazine.Cast(item);
13494 if (quantity >= 0)
13495 {
13496 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13497 }
13498 else
13499 {
13500 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13501 }
13502
13503 }
13504 else
13505 {
13506 if (quantity >= 0)
13507 {
13508 item.SetQuantityNormalized(quantity, false);
13509 }
13510 else
13511 {
13512 item.SetQuantity(Math.AbsFloat(quantity));
13513 }
13514
13515 }
13516 }
13517}
13518
13519#ifdef DEVELOPER
13520ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13521#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/DayZ/Entities/EntityAI.c:2
bool SetAttachSoundEvent()
void InventoryItemType()
bool SetDetachSoundEvent()
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:34
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
string Debug()
Определения CachedEquipmentStorageBase.c:29
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:3942
DayZGame GetDayZGame()
Определения DayZGame.c:3944
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:159
const int MIN
Определения EnConvert.c:28
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:500
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool IsPrepareToDelete()
Определения FireplaceBase.c:643
override bool CanHaveTemperature()
Определения FireplaceBase.c:561
class GP5GasMask extends MaskBase ItemBase
proto GizmoApi GetGizmoApi()
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6453
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5680
bool HidesSelectionBySlot()
Определения ItemBase.c:9413
float m_VarWetMin
Определения ItemBase.c:4937
void SplitItem(PlayerBase player)
Определения ItemBase.c:6908
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9634
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8895
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:8330
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5685
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:9038
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6875
override bool IsHeavyBehaviour()
Определения ItemBase.c:9240
override void SetWetMax()
Определения ItemBase.c:8616
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9451
void ClearStartItemSoundServer()
Определения ItemBase.c:9390
float m_VarWet
Определения ItemBase.c:4934
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9481
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:3
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8890
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4997
bool CanBeMovedOverride()
Определения ItemBase.c:7600
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8592
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4983
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:9358
override void ProcessVariables()
Определения ItemBase.c:9548
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:5011
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8423
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8956
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8806
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5271
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:5009
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9584
bool m_IsSoundSynchRemote
Определения ItemBase.c:9742
float m_OverheatingShots
Определения ItemBase.c:5004
void StopItemSoundServer(int id)
Определения ItemBase.c:9378
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5700
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5424
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9608
ref array< int > m_CompatibleLocks
Определения ItemBase.c:5021
bool CanBeCooked()
Определения ItemBase.c:7556
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5767
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:5035
bool m_RecipesInitialized
Определения ItemBase.c:4919
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6546
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9592
override void OnEnergyConsumed()
Определения ItemBase.c:8536
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:8462
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8656
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8418
ref TIntArray m_InteractActions
Определения ItemBase.c:4985
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7620
float m_VarQuantity
Определения ItemBase.c:4925
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9753
override float GetWetMax()
Определения ItemBase.c:8626
bool CanBeUsedForSuicide()
Определения ItemBase.c:9720
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7193
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5905
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7774
void DoAmmoExplosion()
Определения ItemBase.c:6388
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4996
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6732
int GetItemSize()
Определения ItemBase.c:7585
bool m_CanBeMovedOverride
Определения ItemBase.c:4962
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6312
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5492
bool CanDecay()
Определения ItemBase.c:9523
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:8303
void SetQuantityMax()
Определения ItemBase.c:8308
override float GetQuantity()
Определения ItemBase.c:8398
int m_ColorComponentR
Определения ItemBase.c:4974
int m_ShotsToStartOverheating
Определения ItemBase.c:5006
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8641
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5499
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9139
void OnOverheatingDecay()
Определения ItemBase.c:5462
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8574
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4940
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5600
bool UsesGlobalDeploy()
Определения ItemBase.c:9752
int m_ItemBehaviour
Определения ItemBase.c:4955
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9111
float m_HeatIsolation
Определения ItemBase.c:4950
float m_VarWetInit
Определения ItemBase.c:4936
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5945
void SetCEBasedQuantity()
Определения ItemBase.c:5713
bool m_CanPlayImpactSound
Определения ItemBase.c:4946
override string GetAttachmentSoundType()
Определения ItemBase.c:9314
float GetOverheatingCoef()
Определения ItemBase.c:5519
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9408
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9762
override bool IsStoreLoad()
Определения ItemBase.c:8668
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7169
bool IsLightSource()
Определения ItemBase.c:5841
bool m_HasQuantityBar
Определения ItemBase.c:4968
void SetResultOfSplit(bool value)
Определения ItemBase.c:7164
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6796
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6965
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5527
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8583
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9219
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8678
int m_LockType
Определения ItemBase.c:5022
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:5027
bool m_CanBeDigged
Определения ItemBase.c:4969
float m_ItemAttachOffset
Определения ItemBase.c:4952
float GetItemModelLength()
Определения ItemBase.c:8685
bool m_ThrowItemOnDrop
Определения ItemBase.c:4960
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7919
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8971
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8569
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7198
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9579
bool CanHaveWetness()
Определения ItemBase.c:9536
int m_CleannessMin
Определения ItemBase.c:4942
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8904
string IDToName(int id)
Определения ItemBase.c:7767
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9543
float GetHeatIsolationInit()
Определения ItemBase.c:8564
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7607
override bool HasQuantity()
Определения ItemBase.c:8393
float m_VarWetPrev
Определения ItemBase.c:4935
int m_SoundSyncStop
Определения ItemBase.c:5029
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9629
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4984
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5609
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5294
int m_VarLiquidType
Определения ItemBase.c:4954
int m_QuickBarBonus
Определения ItemBase.c:4956
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9302
override float GetWetInit()
Определения ItemBase.c:8636
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4948
int m_SoundSyncPlay
Определения ItemBase.c:5028
int m_MaxOverheatingValue
Определения ItemBase.c:5007
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4931
bool m_IsTakeable
Определения ItemBase.c:4959
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6503
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4999
string GetLockSoundSet()
Определения ItemBase.c:8734
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8765
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9656
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6971
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4911
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9329
override int GetQuantityMin()
Определения ItemBase.c:8382
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6711
override int GetQuickBarBonus()
Определения ItemBase.c:5179
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
float m_OverheatingDecayInterval
Определения ItemBase.c:5008
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6523
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9501
bool CanProcessDecay()
Определения ItemBase.c:9529
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5690
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9645
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7571
bool can_this_be_combined
Определения ItemBase.c:4964
EffectSound m_SoundDeploy
Определения ItemBase.c:9739
int m_SoundSyncSlotID
Определения ItemBase.c:5030
int m_Count
Определения ItemBase.c:4930
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9692
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9276
override bool IsSplitable()
Определения ItemBase.c:6490
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6473
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7883
void ConvertEnergyToQuantity()
Определения ItemBase.c:8551
override void RemoveAllAgents()
Определения ItemBase.c:8885
override void SetQuantityToMinimum()
Определения ItemBase.c:8314
bool m_WantPlayImpactSound
Определения ItemBase.c:4945
override float GetTemperatureThawTime()
Определения ItemBase.c:9616
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4998
int m_ColorComponentG
Определения ItemBase.c:4975
float m_StoreLoadedQuantity
Определения ItemBase.c:4932
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7638
int m_ColorComponentA
Определения ItemBase.c:4977
int m_VarQuantityInit
Определения ItemBase.c:4927
float GetFilterDamageRatio()
Определения ItemBase.c:5594
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8778
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6942
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:8321
bool m_HideSelectionsBySlot
Определения ItemBase.c:5012
bool IsOverheatingEffectActive()
Определения ItemBase.c:5457
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5874
int GetLiquidContainerMask()
Определения ItemBase.c:5811
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7078
ref Timer m_CheckOverheating
Определения ItemBase.c:5005
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:5505
float GetEnergy()
Определения ItemBase.c:8525
bool CanBeDigged()
Определения ItemBase.c:5890
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9662
bool IsNVG()
Определения ItemBase.c:5822
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8485
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9438
bool m_IsDeploySound
Определения ItemBase.c:9741
bool CanEat()
Определения ItemBase.c:7531
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9179
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9250
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9640
bool IsLiquidContainer()
Определения ItemBase.c:5806
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7551
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8409
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8963
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8363
int m_CleannessInit
Определения ItemBase.c:4941
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5589
override int GetAgents()
Определения ItemBase.c:8910
int m_VarQuantityMax
Определения ItemBase.c:4929
override bool IsHologram()
Определения ItemBase.c:5885
float GetItemAttachOffset()
Определения ItemBase.c:8694
bool IsPlaceSound()
Определения ItemBase.c:9755
static int GetDebugActionsMask()
Определения ItemBase.c:5675
override int GetLiquidType()
Определения ItemBase.c:8794
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9518
override bool IsItemBase()
Определения ItemBase.c:7684
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9260
void ExplodeAmmo()
Определения ItemBase.c:6375
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7154
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8984
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9159
override void OnEnergyAdded()
Определения ItemBase.c:8543
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:5834
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9738
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7824
void StopItemDynamicPhysics()
Определения ItemBase.c:9420
bool HasFoodStage()
Определения ItemBase.c:7544
override void SetStoreLoad(bool value)
Определения ItemBase.c:8663
float GetOverheatingValue()
Определения ItemBase.c:5419
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8863
override void AddWet(float value)
Определения ItemBase.c:8611
bool IsLiquidPresent()
Определения ItemBase.c:5801
bool IsFullQuantity()
Определения ItemBase.c:8403
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6084
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6847
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6823
int m_CleannessMax
Определения ItemBase.c:4943
float m_VarStackMax
Определения ItemBase.c:4931
ref Timer m_PhysDropTimer
Определения ItemBase.c:5018
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7656
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8673
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4972
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5440
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5755
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7578
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8799
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5486
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8721
bool m_IsOverheatingEffectActive
Определения ItemBase.c:5003
int m_LiquidContainerMask
Определения ItemBase.c:4953
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9456
override int GetCleanness()
Определения ItemBase.c:8716
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9667
bool IsDeploySound()
Определения ItemBase.c:9756
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5695
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9199
int m_VarQuantityMin
Определения ItemBase.c:4928
void PerformDamageSystemReinit()
Определения ItemBase.c:9426
override void ClearInventory()
Определения ItemBase.c:8504
static int m_LastRegisteredWeaponID
Определения ItemBase.c:5000
ItemBase GetLightSourceItem()
Определения ItemBase.c:9650
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7674
override float GetItemOverheatThreshold()
Определения ItemBase.c:9600
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4965
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7788
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6762
float m_ItemModelLength
Определения ItemBase.c:4951
bool m_IsHologram
Определения ItemBase.c:4958
static int m_DebugActionsMask
Определения ItemBase.c:4918
void KillAllOverheatingParticles()
Определения ItemBase.c:5555
bool CanBeCookedOnStick()
Определения ItemBase.c:7561
override int GetQuantityMax()
Определения ItemBase.c:8349
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7232
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8759
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8876
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4961
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:9066
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9798
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4912
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9729
override bool IsBeingPlaced()
Определения ItemBase.c:5869
int GetQuantityInit()
Определения ItemBase.c:8387
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7174
bool IsResultOfSplit()
Определения ItemBase.c:7159
bool m_FixDamageSystemInit
Определения ItemBase.c:4963
float m_ImpactSpeed
Определения ItemBase.c:4947
bool m_IsStoreLoad
Определения ItemBase.c:4966
int GetLiquidTypeInit()
Определения ItemBase.c:8789
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4981
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5742
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6633
int m_AttachedAgents
Определения ItemBase.c:4989
string m_LockSoundSet
Определения ItemBase.c:5024
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5363
float m_VarQuantityPrev
Определения ItemBase.c:4926
bool IsSoundSynchRemote()
Определения ItemBase.c:9754
bool m_CanShowQuantity
Определения ItemBase.c:4967
override void OnRightClick()
Определения ItemBase.c:7014
int m_ColorComponentB
Определения ItemBase.c:4976
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4914
bool IsActionTargetVisible()
Определения ItemBase.c:9296
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6119
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6412
bool m_IsBeingPlaced
Определения ItemBase.c:4957
int NameToID(string name)
Определения ItemBase.c:7761
void ~ItemBase()
Определения ItemBase.c:5640
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8651
void ClearStopItemSoundServer()
Определения ItemBase.c:9396
override string ChangeIntoOnDetach()
Определения ItemBase.c:6336
float m_VarWetMax
Определения ItemBase.c:4938
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6757
int GetLockType()
Определения ItemBase.c:8729
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9736
override float GetWet()
Определения ItemBase.c:8621
EffectSound m_SoundPlace
Определения ItemBase.c:9737
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8335
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8703
bool m_IsPlaceSound
Определения ItemBase.c:9740
override float GetWetMin()
Определения ItemBase.c:8631
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:5032
override bool KindOf(string tag)
Определения ItemBase.c:7690
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:336
string GetDebugText()
Определения ModifierBase.c:71
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
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
int GetID()
Определения ActionBase.c:1335
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:974
GetInputType()
Определения ActionBase.c:221
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1325
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:550
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1320
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/DayZ/Entities/Man.c:48
proto native EntityAI GetAttachmentFromIndex(int index)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto void SelectObject(Object object)
proto void SelectPhysics(Physics physics)
Определения ItemBase.c:21
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:507
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:30
override bool CanDisplayCargo()
Определения TentBase.c:91
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:7
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:934
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 string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:397
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:409
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 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
Определения ItemBase.c:14
Определения 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 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:40
proto native float GetDamage(string zoneName, string healthType)
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/DayZ/tools/Debug.c:916
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:113
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
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:515
const int DEF_CHEMICAL
Определения 3_Game/DayZ/constants.c:516
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:712
array< int > TIntArray
Определения EnScript.c:714
void Obsolete(string msg="")
Определения EnScript.c:371
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:811
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/DayZ/constants.c:635
const int VARIABLE_CLEANNESS
Определения 3_Game/DayZ/constants.c:638
const int VARIABLE_COLOR
Определения 3_Game/DayZ/constants.c:637
const int VARIABLE_TEMPERATURE
Определения 3_Game/DayZ/constants.c:633
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:631
const int VARIABLE_WET
Определения 3_Game/DayZ/constants.c:634
const int LIQUID_NONE
Определения 3_Game/DayZ/constants.c:532
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/DayZ/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/DayZ/constants.c:456
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
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/DayZ/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native int GetColor()