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

◆ PreLoadSoundAttachmentType()

void SpawnItemOnLocation::PreLoadSoundAttachmentType ( )
protected

Attachment Sound Type getting from config file.

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

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

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