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

◆ HierarchyCheck()

void SpawnItemOnLocation::HierarchyCheck ( out bool hasParent,
out bool hasRootAsPlayer,
out ItemBase refParentIB )
protected

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

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