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

◆ OnInventoryEnter()

void SpawnItemOnLocation::OnInventoryEnter ( Man player)
protected

Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter.

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

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