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

◆ GetLightSourceItem()

ItemBase SpawnItemOnLocation::GetLightSourceItem ( )
protected

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

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