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

◆ ProcessItemWetness()

void SpawnItemOnLocation::ProcessItemWetness ( float delta,
bool hasParent,
bool hasRootAsPlayer,
ItemBase refParentIB )
protected

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

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