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

◆ GetActionWidgetOverride()

bool SpawnItemOnLocation::GetActionWidgetOverride ( out typename name)
protected

If we need a different (handheld)item action widget displayed, the logic goes in here.

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

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