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

◆ IsSoundSynchRemote()

bool SpawnItemOnLocation::IsSoundSynchRemote ( )
protected

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

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