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

◆ IsStoreLoad()

override bool SpawnItemOnLocation::IsStoreLoad ( )
protected

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

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

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