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

◆ CanPlayDeployLoopSound()

bool SpawnItemOnLocation::CanPlayDeployLoopSound ( )
protected

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

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