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

◆ OnInventoryExit()

void SpawnItemOnLocation::OnInventoryExit ( Man player)
protected

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

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

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