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

◆ ClearInventory()

override void SpawnItemOnLocation::ClearInventory ( )
protected

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

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

Используется в PluginBase::OnRPCClearInventory().