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

◆ ProcessItemWetnessAndTemperature()

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

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

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