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

◆ SetWetMax()

override void SpawnItemOnLocation::SetWetMax ( )
protected

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

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