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

◆ RemoveLightSourceItem()

void SpawnItemOnLocation::RemoveLightSourceItem ( )
protected

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

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