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

◆ CopyScriptPropertiesFrom()

void SpawnItemOnLocation::CopyScriptPropertiesFrom ( EntityAI oldItem)
protected

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

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