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

◆ CanDecay()

BrisketSpread Edible_Base CanDecay ( )
protected

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

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

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