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

◆ TransferAgents()

void SpawnItemOnLocation::TransferAgents ( int agents)
protected

transfer agents from another item

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

8808{
8809 override bool CanPutAsAttachment(EntityAI parent)
8810 {
8811 return true;
8812 }
8813};
8814
8815//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8816
8817class ItemBase extends InventoryItem
8818{
8822
8824
8825 static int m_DebugActionsMask;
8827 // ============================================
8828 // Variable Manipulation System
8829 // ============================================
8830 // Quantity
8831
8832 float m_VarQuantity;
8833 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8835 int m_VarQuantityMin;
8836 int m_VarQuantityMax;
8837 int m_Count;
8838 float m_VarStackMax;
8839 float m_StoreLoadedQuantity = float.LOWEST;
8840 // Wet
8841 float m_VarWet;
8842 float m_VarWetPrev;//for client to know wetness changed during synchronization
8843 float m_VarWetInit;
8844 float m_VarWetMin;
8845 float m_VarWetMax;
8846 // Cleanness
8847 int m_Cleanness;
8848 int m_CleannessInit;
8849 int m_CleannessMin;
8850 int m_CleannessMax;
8851 // impact sounds
8853 bool m_CanPlayImpactSound = true;
8854 float m_ImpactSpeed;
8856 //
8857 float m_HeatIsolation;
8858 float m_ItemModelLength;
8859 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8861 int m_VarLiquidType;
8862 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8863 int m_QuickBarBonus;
8864 bool m_IsBeingPlaced;
8865 bool m_IsHologram;
8866 bool m_IsTakeable;
8867 bool m_ThrowItemOnDrop;
8870 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8871 bool can_this_be_combined; //Check if item can be combined
8872 bool m_CanThisBeSplit; //Check if item can be split
8873 bool m_IsStoreLoad = false;
8874 bool m_CanShowQuantity;
8875 bool m_HasQuantityBar;
8876 protected bool m_CanBeDigged;
8877 protected bool m_IsResultOfSplit
8878
8879 string m_SoundAttType;
8880 // items color variables
8885 //-------------------------------------------------------
8886
8887 // light source managing
8889
8893
8894 //==============================================
8895 // agent system
8896 private int m_AttachedAgents;
8897
8899 void TransferModifiers(PlayerBase reciever);
8900
8901
8902 // Weapons & suppressors particle effects
8907 static int m_LastRegisteredWeaponID = 0;
8908
8909 // Overheating effects
8911 float m_OverheatingShots;
8912 ref Timer m_CheckOverheating;
8913 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8914 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8915 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8916 ref array <ref OverheatingParticle> m_OverheatingParticles;
8917
8919 protected bool m_HideSelectionsBySlot;
8920
8921 // Admin Log
8922 PluginAdminLog m_AdminLog;
8923
8924 // misc
8925 ref Timer m_PhysDropTimer;
8926
8927 // Attachment Locking variables
8928 ref array<int> m_CompatibleLocks;
8929 protected int m_LockType;
8930 protected ref EffectSound m_LockingSound;
8931 protected string m_LockSoundSet;
8932
8933 // ItemSoundHandler
8934 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8935 protected int m_SoundSyncPlay; // id for sound to play
8936 protected int m_SoundSyncStop; // id for sound to stop
8938
8939 //temperature
8940 private float m_TemperaturePerQuantityWeight;
8941
8942 // -------------------------------------------------------------------------
8943 void ItemBase()
8944 {
8945 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8949
8950 if (!GetGame().IsDedicatedServer())
8951 {
8952 if (HasMuzzle())
8953 {
8955
8957 {
8959 }
8960 }
8961
8963 m_ActionsInitialize = false;
8964 }
8965
8966 m_OldLocation = null;
8967
8968 if (GetGame().IsServer())
8969 {
8970 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8971 }
8972
8973 if (ConfigIsExisting("headSelectionsToHide"))
8974 {
8976 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8977 }
8978
8979 m_HideSelectionsBySlot = false;
8980 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8981 {
8982 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8983 }
8984
8985 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8986
8987 m_IsResultOfSplit = false;
8988
8990 }
8991
8992 override void InitItemVariables()
8993 {
8994 super.InitItemVariables();
8995
8996 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8997 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8998 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8999 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
9000 m_VarStackMax = ConfigGetFloat("varStackMax");
9001 m_Count = ConfigGetInt("count");
9002
9003 m_CanShowQuantity = ConfigGetBool("quantityShow");
9004 m_HasQuantityBar = ConfigGetBool("quantityBar");
9005
9006 m_CleannessInit = ConfigGetInt("varCleannessInit");
9008 m_CleannessMin = ConfigGetInt("varCleannessMin");
9009 m_CleannessMax = ConfigGetInt("varCleannessMax");
9010
9011 m_WantPlayImpactSound = false;
9012 m_ImpactSpeed = 0.0;
9013
9014 m_VarWetInit = ConfigGetFloat("varWetInit");
9016 m_VarWetMin = ConfigGetFloat("varWetMin");
9017 m_VarWetMax = ConfigGetFloat("varWetMax");
9018
9019 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
9020 if (IsLiquidContainer() && GetQuantity() != 0)
9022 m_IsBeingPlaced = false;
9023 m_IsHologram = false;
9024 m_IsTakeable = true;
9025 m_CanBeMovedOverride = false;
9029 m_CanBeDigged = ConfigGetBool("canBeDigged");
9030
9031 m_CompatibleLocks = new array<int>();
9032 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
9033 m_LockType = ConfigGetInt("lockType");
9034
9035 //Define if item can be split and set ability to be combined accordingly
9036 m_CanThisBeSplit = false;
9037 can_this_be_combined = false;
9038 if (ConfigIsExisting("canBeSplit"))
9039 {
9040 can_this_be_combined = ConfigGetBool("canBeSplit");
9042 }
9043
9044 m_ItemBehaviour = -1;
9045 if (ConfigIsExisting("itemBehaviour"))
9046 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
9047
9048 //RegisterNetSyncVariableInt("m_VariablesMask");
9049 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9050 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
9051 RegisterNetSyncVariableInt("m_VarLiquidType");
9052 RegisterNetSyncVariableInt("m_Cleanness",0,1);
9053
9054 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
9055 RegisterNetSyncVariableFloat("m_ImpactSpeed");
9056 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
9057
9058 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
9059 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
9060 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
9061 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
9062
9063 RegisterNetSyncVariableBool("m_IsBeingPlaced");
9064 RegisterNetSyncVariableBool("m_IsTakeable");
9065 RegisterNetSyncVariableBool("m_IsHologram");
9066
9067 InitItemSounds();
9069 {
9070 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
9071 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
9072 }
9073
9074 m_LockSoundSet = ConfigGetString("lockSoundSet");
9075
9077 if (ConfigIsExisting("temperaturePerQuantityWeight"))
9078 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
9079
9080 }
9081
9082 override int GetQuickBarBonus()
9083 {
9084 return m_QuickBarBonus;
9085 }
9086
9087 void InitializeActions()
9088 {
9090 if (!m_InputActionMap)
9091 {
9093 m_InputActionMap = iam;
9094 SetActions();
9096 }
9097 }
9098
9099 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
9100 {
9102 {
9103 m_ActionsInitialize = true;
9105 }
9106
9107 actions = m_InputActionMap.Get(action_input_type);
9108 }
9109
9110 void SetActions()
9111 {
9112 AddAction(ActionTakeItem);
9113 AddAction(ActionTakeItemToHands);
9114 AddAction(ActionWorldCraft);
9116 AddAction(ActionAttachWithSwitch);
9117 }
9118
9119 void SetActionAnimOverrides(); // Override action animation for specific item
9120
9121 void AddAction(typename actionName)
9122 {
9123 ActionBase action = ActionManagerBase.GetAction(actionName);
9124
9125 if (!action)
9126 {
9127 Debug.LogError("Action " + actionName + " dosn't exist!");
9128 return;
9129 }
9130
9131 typename ai = action.GetInputType();
9132 if (!ai)
9133 {
9134 m_ActionsInitialize = false;
9135 return;
9136 }
9137
9138 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9139 if (!action_array)
9140 {
9141 action_array = new array<ActionBase_Basic>;
9142 m_InputActionMap.Insert(ai, action_array);
9143 }
9144 if (LogManager.IsActionLogEnable())
9145 {
9146 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9147 }
9148
9149 if (action_array.Find(action) != -1)
9150 {
9151 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
9152 }
9153 else
9154 {
9155 action_array.Insert(action);
9156 }
9157 }
9158
9159 void RemoveAction(typename actionName)
9160 {
9161 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9162 ActionBase action = player.GetActionManager().GetAction(actionName);
9163 typename ai = action.GetInputType();
9164 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9165
9166 if (action_array)
9167 {
9168 action_array.RemoveItem(action);
9169 }
9170 }
9171
9172 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
9173 // Set -1 for params which should stay in default state
9174 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
9175 {
9176 ActionOverrideData overrideData = new ActionOverrideData();
9177 overrideData.m_CommandUID = commandUID;
9178 overrideData.m_CommandUIDProne = commandUIDProne;
9179 overrideData.m_StanceMask = stanceMask;
9180
9181 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
9182 if (!actionMap) // create new map of action > overidables map
9183 {
9184 actionMap = new TActionAnimOverrideMap();
9185 m_ItemActionOverrides.Insert(action, actionMap);
9186 }
9187
9188 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9189
9190 }
9191
9192 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9193
9194 ScriptedLightBase GetLight();
9195
9196 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9197 void LoadParticleConfigOnFire(int id)
9198 {
9199 if (!m_OnFireEffect)
9201
9204
9205 string config_to_search = "CfgVehicles";
9206 string muzzle_owner_config;
9207
9208 if (!m_OnFireEffect.Contains(id))
9209 {
9210 if (IsInherited(Weapon))
9211 config_to_search = "CfgWeapons";
9212
9213 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9214
9215 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9216
9217 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
9218
9219 if (config_OnFire_subclass_count > 0)
9220 {
9221 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9222
9223 for (int i = 0; i < config_OnFire_subclass_count; i++)
9224 {
9225 string particle_class = "";
9226 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
9227 string config_OnFire_entry = config_OnFire_class + particle_class;
9228 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9229 WPOF_array.Insert(WPOF);
9230 }
9231
9232
9233 m_OnFireEffect.Insert(id, WPOF_array);
9234 }
9235 }
9236
9237 if (!m_OnBulletCasingEjectEffect.Contains(id))
9238 {
9239 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9240 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9241
9242 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9243
9244 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9245
9246 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9247 {
9248 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9249
9250 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9251 {
9252 string particle_class2 = "";
9253 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9254 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9255 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9256 WPOBE_array.Insert(WPOBE);
9257 }
9258
9259
9260 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9261 }
9262 }
9263 }
9264
9265 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9267 {
9270
9271 if (!m_OnOverheatingEffect.Contains(id))
9272 {
9273 string config_to_search = "CfgVehicles";
9274
9275 if (IsInherited(Weapon))
9276 config_to_search = "CfgWeapons";
9277
9278 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9279 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9280
9281 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
9282 {
9283
9284 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9285
9287 {
9288 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9289 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9290 Error(error);
9291 return;
9292 }
9293
9294 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9295 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9296
9297
9298
9299 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
9300 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9301
9302 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9303 {
9304 string particle_class = "";
9305 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9306 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9307 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
9308
9309 if (entry_type == CT_CLASS)
9310 {
9311 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9312 WPOOH_array.Insert(WPOF);
9313 }
9314 }
9315
9316
9317 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9318 }
9319 }
9320 }
9321
9322 float GetOverheatingValue()
9323 {
9324 return m_OverheatingShots;
9325 }
9326
9327 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9328 {
9329 if (m_MaxOverheatingValue > 0)
9330 {
9332
9333 if (!m_CheckOverheating)
9335
9337 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9338
9339 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9340 }
9341 }
9342
9343 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9344 {
9346 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9347
9349 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9350
9352 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9353
9355 {
9357 }
9358 }
9359
9361 {
9363 }
9364
9365 void OnOverheatingDecay()
9366 {
9367 if (m_MaxOverheatingValue > 0)
9368 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9369 else
9371
9372 if (m_OverheatingShots <= 0)
9373 {
9376 }
9377 else
9378 {
9379 if (!m_CheckOverheating)
9381
9383 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9384 }
9385
9386 CheckOverheating(this, "", this);
9387 }
9388
9389 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9390 {
9392 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9393 }
9394
9395 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9396 {
9398 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9400 }
9401
9402 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9403 {
9405 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9406 }
9407
9408 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9409 {
9411 m_OverheatingParticles = new array<ref OverheatingParticle>;
9412
9413 OverheatingParticle OP = new OverheatingParticle();
9414 OP.RegisterParticle(p);
9415 OP.SetOverheatingLimitMin(min_heat_coef);
9416 OP.SetOverheatingLimitMax(max_heat_coef);
9417 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9418
9419 m_OverheatingParticles.Insert(OP);
9420 }
9421
9422 float GetOverheatingCoef()
9423 {
9424 if (m_MaxOverheatingValue > 0)
9426
9427 return -1;
9428 }
9429
9431 {
9433 {
9434 float overheat_coef = GetOverheatingCoef();
9435 int count = m_OverheatingParticles.Count();
9436
9437 for (int i = count; i > 0; --i)
9438 {
9439 int id = i - 1;
9440 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9441 Particle p = OP.GetParticle();
9442
9443 float overheat_min = OP.GetOverheatingLimitMin();
9444 float overheat_max = OP.GetOverheatingLimitMax();
9445
9446 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9447 {
9448 if (p)
9449 {
9450 p.Stop();
9451 OP.RegisterParticle(null);
9452 }
9453 }
9454 }
9455 }
9456 }
9457
9459 {
9461 {
9462 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9463 {
9464 int id = i - 1;
9465 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9466
9467 if (OP)
9468 {
9469 Particle p = OP.GetParticle();
9470
9471 if (p)
9472 {
9473 p.Stop();
9474 }
9475
9476 delete OP;
9477 }
9478 }
9479
9480 m_OverheatingParticles.Clear();
9482 }
9483 }
9484
9486 float GetInfectionChance(int system = 0, Param param = null)
9487 {
9488 return 0.0;
9489 }
9490
9491
9492 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9493 {
9494 return 250;//default value
9495 }
9496
9497 float GetFilterDamageRatio()
9498 {
9499 return 0;
9500 }
9501
9503 bool HasMuzzle()
9504 {
9505 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9506 return true;
9507
9508 return false;
9509 }
9510
9512 int GetMuzzleID()
9513 {
9514 if (!m_WeaponTypeToID)
9516
9517 if (m_WeaponTypeToID.Contains(GetType()))
9518 {
9519 return m_WeaponTypeToID.Get(GetType());
9520 }
9521 else
9522 {
9523 // Register new weapon ID
9525 }
9526
9528 }
9529
9536 {
9537 return -1;
9538 }
9539
9540
9541
9542 // -------------------------------------------------------------------------
9543 void ~ItemBase()
9544 {
9545 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
9546 {
9547 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9548 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9549
9550 if (r_index >= 0)
9551 {
9552 InventoryLocation r_il = new InventoryLocation;
9553 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9554
9555 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9556 int r_type = r_il.GetType();
9557 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9558 {
9559 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9560 }
9561 else if (r_type == InventoryLocationType.ATTACHMENT)
9562 {
9563 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9564 }
9565
9566 }
9567
9568 player.GetHumanInventory().ClearUserReservedLocation(this);
9569 }
9570
9571 if (m_LockingSound)
9572 SEffectManager.DestroyEffect(m_LockingSound);
9573 }
9574
9575
9576
9577 // -------------------------------------------------------------------------
9578 static int GetDebugActionsMask()
9579 {
9580 return ItemBase.m_DebugActionsMask;
9581 }
9582
9583 static bool HasDebugActionsMask(int mask)
9584 {
9585 return ItemBase.m_DebugActionsMask & mask;
9586 }
9587
9588 static void SetDebugActionsMask(int mask)
9589 {
9590 ItemBase.m_DebugActionsMask = mask;
9591 }
9592
9593 static void AddDebugActionsMask(int mask)
9594 {
9595 ItemBase.m_DebugActionsMask |= mask;
9596 }
9597
9598 static void RemoveDebugActionsMask(int mask)
9599 {
9600 ItemBase.m_DebugActionsMask &= ~mask;
9601 }
9602
9603 static void ToggleDebugActionsMask(int mask)
9604 {
9605 if (HasDebugActionsMask(mask))
9606 {
9608 }
9609 else
9610 {
9611 AddDebugActionsMask(mask);
9612 }
9613 }
9614
9615 // -------------------------------------------------------------------------
9616 void SetCEBasedQuantity()
9617 {
9618 if (GetEconomyProfile())
9619 {
9620 float q_max = GetEconomyProfile().GetQuantityMax();
9621 if (q_max > 0)
9622 {
9623 float q_min = GetEconomyProfile().GetQuantityMin();
9624 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9625
9626 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9627 {
9628 ComponentEnergyManager comp = GetCompEM();
9629 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
9630 {
9631 comp.SetEnergy0To1(quantity_randomized);
9632 }
9633 }
9634 else if (HasQuantity())
9635 {
9636 SetQuantityNormalized(quantity_randomized, false);
9637 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9638 }
9639
9640 }
9641 }
9642 }
9643
9645 void LockToParent()
9646 {
9647 EntityAI parent = GetHierarchyParent();
9648
9649 if (parent)
9650 {
9651 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9652 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9653 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9654 }
9655 }
9656
9658 void UnlockFromParent()
9659 {
9660 EntityAI parent = GetHierarchyParent();
9661
9662 if (parent)
9663 {
9664 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9665 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9666 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9667 }
9668 }
9669
9670 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9671 {
9672 /*
9673 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9674 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
9675 */
9676 ItemBase item2 = ItemBase.Cast(entity2);
9677
9678 if (GetGame().IsClient())
9679 {
9680 if (ScriptInputUserData.CanStoreInputUserData())
9681 {
9682 ScriptInputUserData ctx = new ScriptInputUserData;
9684 ctx.Write(-1);
9685 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9686 ctx.Write(i1);
9687 ctx.Write(item2);
9688 ctx.Write(use_stack_max);
9689 ctx.Write(-1);
9690 ctx.Send();
9691
9692 if (IsCombineAll(item2, use_stack_max))
9693 {
9694 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9695 }
9696 }
9697 }
9698 else if (!GetGame().IsMultiplayer())
9699 {
9700 CombineItems(item2, use_stack_max);
9701 }
9702 }
9703
9704 bool IsLiquidPresent()
9705 {
9706 return (GetLiquidType() != 0 && HasQuantity());
9707 }
9708
9709 bool IsLiquidContainer()
9710 {
9711 return m_LiquidContainerMask != 0;
9712 }
9713
9715 {
9716 return m_LiquidContainerMask;
9717 }
9718
9719 bool IsBloodContainer()
9720 {
9721 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9722 return false;
9723 }
9724
9725 bool IsNVG()
9726 {
9727 return false;
9728 }
9729
9732 bool IsExplosive()
9733 {
9734 return false;
9735 }
9736
9738 {
9739 return "";
9740 }
9741
9743
9744 bool IsLightSource()
9745 {
9746 return false;
9747 }
9748
9750 {
9751 return true;
9752 }
9753
9754 //--- ACTION CONDITIONS
9755 //direction
9756 bool IsFacingPlayer(PlayerBase player, string selection)
9757 {
9758 return true;
9759 }
9760
9761 bool IsPlayerInside(PlayerBase player, string selection)
9762 {
9763 return true;
9764 }
9765
9766 override bool CanObstruct()
9767 {
9768 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9769 return !player || !IsPlayerInside(player, "");
9770 }
9771
9772 override bool IsBeingPlaced()
9773 {
9774 return m_IsBeingPlaced;
9775 }
9776
9777 void SetIsBeingPlaced(bool is_being_placed)
9778 {
9779 m_IsBeingPlaced = is_being_placed;
9780 if (!is_being_placed)
9782 SetSynchDirty();
9783 }
9784
9785 //server-side
9786 void OnEndPlacement() {}
9787
9788 override bool IsHologram()
9789 {
9790 return m_IsHologram;
9791 }
9792
9793 bool CanBeDigged()
9794 {
9795 return m_CanBeDigged;
9796 }
9797
9799 {
9800 return 1;
9801 }
9802
9803 bool CanMakeGardenplot()
9804 {
9805 return false;
9806 }
9807
9808 void SetIsHologram(bool is_hologram)
9809 {
9810 m_IsHologram = is_hologram;
9811 SetSynchDirty();
9812 }
9813 /*
9814 protected float GetNutritionalEnergy()
9815 {
9816 Edible_Base edible = Edible_Base.Cast(this);
9817 return edible.GetFoodEnergy();
9818 }
9819
9820 protected float GetNutritionalWaterContent()
9821 {
9822 Edible_Base edible = Edible_Base.Cast(this);
9823 return edible.GetFoodWater();
9824 }
9825
9826 protected float GetNutritionalIndex()
9827 {
9828 Edible_Base edible = Edible_Base.Cast(this);
9829 return edible.GetFoodNutritionalIndex();
9830 }
9831
9832 protected float GetNutritionalFullnessIndex()
9833 {
9834 Edible_Base edible = Edible_Base.Cast(this);
9835 return edible.GetFoodTotalVolume();
9836 }
9837
9838 protected float GetNutritionalToxicity()
9839 {
9840 Edible_Base edible = Edible_Base.Cast(this);
9841 return edible.GetFoodToxicity();
9842
9843 }
9844 */
9845
9846
9847 // -------------------------------------------------------------------------
9848 override void OnMovedInsideCargo(EntityAI container)
9849 {
9850 super.OnMovedInsideCargo(container);
9851
9852 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9853 }
9854
9855 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9856 {
9857 super.EEItemLocationChanged(oldLoc,newLoc);
9858
9859 PlayerBase new_player = null;
9860 PlayerBase old_player = null;
9861
9862 if (newLoc.GetParent())
9863 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9864
9865 if (oldLoc.GetParent())
9866 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9867
9868 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
9869 {
9870 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
9871
9872 if (r_index >= 0)
9873 {
9874 InventoryLocation r_il = new InventoryLocation;
9875 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9876
9877 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9878 int r_type = r_il.GetType();
9879 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9880 {
9881 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9882 }
9883 else if (r_type == InventoryLocationType.ATTACHMENT)
9884 {
9885 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9886 }
9887
9888 }
9889 }
9890
9891 if (newLoc.GetType() == InventoryLocationType.HANDS)
9892 {
9893 if (new_player)
9894 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
9895
9896 if (new_player == old_player)
9897 {
9898
9899 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9900 {
9901 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9902 {
9903 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9904 {
9905 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9906 }
9907 }
9908 else
9909 {
9910 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9911 }
9912 }
9913
9914 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9915 {
9916 int type = oldLoc.GetType();
9917 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9918 {
9919 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9920 }
9921 else if (type == InventoryLocationType.ATTACHMENT)
9922 {
9923 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9924 }
9925 }
9926 if (!m_OldLocation)
9927 {
9928 m_OldLocation = new InventoryLocation;
9929 }
9930 m_OldLocation.Copy(oldLoc);
9931 }
9932 else
9933 {
9934 if (m_OldLocation)
9935 {
9936 m_OldLocation.Reset();
9937 }
9938 }
9939
9941 }
9942 else
9943 {
9944 if (new_player)
9945 {
9946 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9947 if (res_index >= 0)
9948 {
9949 InventoryLocation il = new InventoryLocation;
9950 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
9951 ItemBase it = ItemBase.Cast(il.GetItem());
9952 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
9953 int rel_type = il.GetType();
9954 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9955 {
9956 il.GetParent().GetOnReleaseLock().Invoke(it);
9957 }
9958 else if (rel_type == InventoryLocationType.ATTACHMENT)
9959 {
9960 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9961 }
9962 //it.GetOnReleaseLock().Invoke(it);
9963 }
9964 }
9965 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9966 {
9967 //ThrowPhysically(old_player, vector.Zero);
9968 m_ThrowItemOnDrop = false;
9969 }
9970
9971 if (m_OldLocation)
9972 {
9973 m_OldLocation.Reset();
9974 }
9975 }
9976 }
9977
9978 override void EOnContact(IEntity other, Contact extra)
9979 {
9981 {
9982 int liquidType = -1;
9983 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9984 if (impactSpeed > 0.0)
9985 {
9986 m_ImpactSpeed = impactSpeed;
9987 #ifndef SERVER
9988 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9989 #else
9990 m_WantPlayImpactSound = true;
9991 SetSynchDirty();
9992 #endif
9993 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9994 }
9995 }
9996
9997 #ifdef SERVER
9998 if (GetCompEM() && GetCompEM().IsPlugged())
9999 {
10000 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
10001 GetCompEM().UnplugThis();
10002 }
10003 #endif
10004 }
10005
10006 void RefreshPhysics();
10007
10008 override void OnCreatePhysics()
10009 {
10011 }
10012
10013 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10014 {
10015
10016 }
10017 // -------------------------------------------------------------------------
10018 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
10019 {
10020 super.OnItemLocationChanged(old_owner, new_owner);
10021
10022 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
10023 PlayerBase playerNew = PlayerBase.Cast(new_owner);
10024
10025 if (!relatedPlayer && playerNew)
10026 relatedPlayer = playerNew;
10027
10028 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
10029 {
10030 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
10031 if (actionMgr)
10032 {
10033 ActionBase currentAction = actionMgr.GetRunningAction();
10034 if (currentAction)
10035 currentAction.OnItemLocationChanged(this);
10036 }
10037 }
10038
10039 Man ownerPlayerOld = null;
10040 Man ownerPlayerNew = null;
10041
10042 if (old_owner)
10043 {
10044 if (old_owner.IsMan())
10045 {
10046 ownerPlayerOld = Man.Cast(old_owner);
10047 }
10048 else
10049 {
10050 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
10051 }
10052 }
10053 else
10054 {
10055 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
10056 {
10057 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
10058
10059 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
10060 {
10061 GetCompEM().UnplugThis();
10062 }
10063 }
10064 }
10065
10066 if (new_owner)
10067 {
10068 if (new_owner.IsMan())
10069 {
10070 ownerPlayerNew = Man.Cast(new_owner);
10071 }
10072 else
10073 {
10074 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
10075 }
10076 }
10077
10078 if (ownerPlayerOld != ownerPlayerNew)
10079 {
10080 if (ownerPlayerOld)
10081 {
10082 array<EntityAI> subItemsExit = new array<EntityAI>;
10083 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
10084 for (int i = 0; i < subItemsExit.Count(); i++)
10085 {
10086 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
10087 itemExit.OnInventoryExit(ownerPlayerOld);
10088 }
10089 }
10090
10091 if (ownerPlayerNew)
10092 {
10093 array<EntityAI> subItemsEnter = new array<EntityAI>;
10094 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
10095 for (int j = 0; j < subItemsEnter.Count(); j++)
10096 {
10097 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
10098 itemEnter.OnInventoryEnter(ownerPlayerNew);
10099 }
10100 }
10101 }
10102 else if (ownerPlayerNew != null)
10103 {
10104 PlayerBase nplayer;
10105 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
10106 {
10107 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10108 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10109 for (int k = 0; k < subItemsUpdate.Count(); k++)
10110 {
10111 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10112 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10113 }
10114 }
10115 }
10116
10117 if (old_owner)
10118 old_owner.OnChildItemRemoved(this);
10119 if (new_owner)
10120 new_owner.OnChildItemReceived(this);
10121 }
10122
10123 // -------------------------------------------------------------------------------
10124 override void EEDelete(EntityAI parent)
10125 {
10126 super.EEDelete(parent);
10127 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10128 if (player)
10129 {
10130 OnInventoryExit(player);
10131
10132 if (player.IsAlive())
10133 {
10134 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10135 if (r_index >= 0)
10136 {
10137 InventoryLocation r_il = new InventoryLocation;
10138 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10139
10140 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10141 int r_type = r_il.GetType();
10142 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10143 {
10144 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10145 }
10146 else if (r_type == InventoryLocationType.ATTACHMENT)
10147 {
10148 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10149 }
10150
10151 }
10152
10153 player.RemoveQuickBarEntityShortcut(this);
10154 }
10155 }
10156 }
10157 // -------------------------------------------------------------------------------
10158 override void EEKilled(Object killer)
10159 {
10160 super.EEKilled(killer);
10161
10163 if (killer && killer.IsFireplace() && CanExplodeInFire())
10164 {
10165 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
10166 {
10167 if (IsMagazine())
10168 {
10169 if (Magazine.Cast(this).GetAmmoCount() > 0)
10170 {
10171 ExplodeAmmo();
10172 }
10173 }
10174 else
10175 {
10176 Explode(DamageType.EXPLOSION);
10177 }
10178 }
10179 }
10180 }
10181
10182 override void OnWasAttached(EntityAI parent, int slot_id)
10183 {
10184 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10185
10186 super.OnWasAttached(parent, slot_id);
10187
10188 if (HasQuantity())
10189 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10190
10191 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
10192 }
10193
10194 override void OnWasDetached(EntityAI parent, int slot_id)
10195 {
10196 super.OnWasDetached(parent, slot_id);
10197
10198 if (HasQuantity())
10199 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10200 }
10201
10202 override string ChangeIntoOnAttach(string slot)
10203 {
10204 int idx;
10205 TStringArray inventory_slots = new TStringArray;
10206 TStringArray attach_types = new TStringArray;
10207
10208 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10209 if (inventory_slots.Count() < 1) //is string
10210 {
10211 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10212 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10213 }
10214 else //is array
10215 {
10216 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10217 }
10218
10219 idx = inventory_slots.Find(slot);
10220 if (idx < 0)
10221 return "";
10222
10223 return attach_types.Get(idx);
10224 }
10225
10226 override string ChangeIntoOnDetach()
10227 {
10228 int idx = -1;
10229 string slot;
10230
10231 TStringArray inventory_slots = new TStringArray;
10232 TStringArray detach_types = new TStringArray;
10233
10234 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10235 if (inventory_slots.Count() < 1) //is string
10236 {
10237 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10238 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10239 }
10240 else //is array
10241 {
10242 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10243 if (detach_types.Count() < 1)
10244 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10245 }
10246
10247 for (int i = 0; i < inventory_slots.Count(); i++)
10248 {
10249 slot = inventory_slots.Get(i);
10250 }
10251
10252 if (slot != "")
10253 {
10254 if (detach_types.Count() == 1)
10255 idx = 0;
10256 else
10257 idx = inventory_slots.Find(slot);
10258 }
10259 if (idx < 0)
10260 return "";
10261
10262 return detach_types.Get(idx);
10263 }
10264
10265 void ExplodeAmmo()
10266 {
10267 //timer
10268 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10269
10270 //min/max time
10271 float min_time = 1;
10272 float max_time = 3;
10273 float delay = Math.RandomFloat(min_time, max_time);
10274
10275 explode_timer.Run(delay, this, "DoAmmoExplosion");
10276 }
10277
10278 void DoAmmoExplosion()
10279 {
10280 Magazine magazine = Magazine.Cast(this);
10281 int pop_sounds_count = 6;
10282 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10283
10284 //play sound
10285 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10286 string sound_name = pop_sounds[ sound_idx ];
10287 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
10288
10289 //remove ammo count
10290 magazine.ServerAddAmmoCount(-1);
10291
10292 //if condition then repeat -> ExplodeAmmo
10293 float min_temp_to_explode = 100; //min temperature for item to explode
10294
10295 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10296 {
10297 ExplodeAmmo();
10298 }
10299 }
10300
10301 // -------------------------------------------------------------------------------
10302 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10303 {
10304 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10305
10306 const int CHANCE_DAMAGE_CARGO = 4;
10307 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10308 const int CHANCE_DAMAGE_NOTHING = 2;
10309
10310 if (IsClothing() || IsContainer() || IsItemTent())
10311 {
10312 float dmg = damageResult.GetDamage("","Health") * -0.5;
10313 int chances;
10314 int rnd;
10315
10316 if (GetInventory().GetCargo())
10317 {
10318 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10319 rnd = Math.RandomInt(0,chances);
10320
10321 if (rnd < CHANCE_DAMAGE_CARGO)
10322 {
10323 DamageItemInCargo(dmg);
10324 }
10325 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10326 {
10328 }
10329 }
10330 else
10331 {
10332 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10333 rnd = Math.RandomInt(0,chances);
10334
10335 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10336 {
10338 }
10339 }
10340 }
10341 }
10342
10343 bool DamageItemInCargo(float damage)
10344 {
10345 if (GetInventory().GetCargo())
10346 {
10347 int item_count = GetInventory().GetCargo().GetItemCount();
10348 if (item_count > 0)
10349 {
10350 int random_pick = Math.RandomInt(0, item_count);
10351 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
10352 if (!item.IsExplosive())
10353 {
10354 item.AddHealth("","",damage);
10355 return true;
10356 }
10357 }
10358 }
10359 return false;
10360 }
10361
10362 bool DamageItemAttachments(float damage)
10363 {
10364 int attachment_count = GetInventory().AttachmentCount();
10365 if (attachment_count > 0)
10366 {
10367 int random_pick = Math.RandomInt(0, attachment_count);
10368 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
10369 if (!attachment.IsExplosive())
10370 {
10371 attachment.AddHealth("","",damage);
10372 return true;
10373 }
10374 }
10375 return false;
10376 }
10377
10378 override bool IsSplitable()
10379 {
10380 return m_CanThisBeSplit;
10381 }
10382 //----------------
10383 override bool CanBeSplit()
10384 {
10385 if (IsSplitable() && (GetQuantity() > 1))
10386 return GetInventory().CanRemoveEntity();
10387
10388 return false;
10389 }
10390
10391 protected bool ShouldSplitQuantity(float quantity)
10392 {
10393 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10394 if (!IsSplitable())
10395 return false;
10396
10397 // nothing to split?
10398 if (GetQuantity() <= 1)
10399 return false;
10400
10401 // check if we should re-use the item instead of creating a new copy?
10402 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10403 int delta = GetQuantity() - quantity;
10404 if (delta == 0)
10405 return false;
10406
10407 // valid to split
10408 return true;
10409 }
10410
10411 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10412 {
10413 if (GetGame().IsClient())
10414 {
10415 if (ScriptInputUserData.CanStoreInputUserData())
10416 {
10417 ScriptInputUserData ctx = new ScriptInputUserData;
10419 ctx.Write(1);
10420 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10421 ctx.Write(i1);
10422 ctx.Write(destination_entity);
10423 ctx.Write(true);
10424 ctx.Write(slot_id);
10425 ctx.Send();
10426 }
10427 }
10428 else if (!GetGame().IsMultiplayer())
10429 {
10430 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
10431 }
10432 }
10433
10434 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10435 {
10436 float split_quantity_new;
10437 ItemBase new_item;
10438 float quantity = GetQuantity();
10439 float stack_max = GetTargetQuantityMax(slot_id);
10440 InventoryLocation loc = new InventoryLocation;
10441
10442 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10443 {
10444 if (stack_max <= GetQuantity())
10445 split_quantity_new = stack_max;
10446 else
10447 split_quantity_new = GetQuantity();
10448
10449 if (ShouldSplitQuantity(split_quantity_new))
10450 {
10451 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10452 if (new_item)
10453 {
10454 new_item.SetResultOfSplit(true);
10455 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10456 AddQuantity(-split_quantity_new, false, true);
10457 new_item.SetQuantity(split_quantity_new, false, true);
10458 }
10459 }
10460 }
10461 else if (destination_entity && slot_id == -1)
10462 {
10463 if (quantity > stack_max)
10464 split_quantity_new = stack_max;
10465 else
10466 split_quantity_new = quantity;
10467
10468 if (ShouldSplitQuantity(split_quantity_new))
10469 {
10470 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10471 {
10472 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10473 new_item = ItemBase.Cast(o);
10474 }
10475
10476 if (new_item)
10477 {
10478 new_item.SetResultOfSplit(true);
10479 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10480 AddQuantity(-split_quantity_new, false, true);
10481 new_item.SetQuantity(split_quantity_new, false, true);
10482 }
10483 }
10484 }
10485 else
10486 {
10487 if (stack_max != 0)
10488 {
10489 if (stack_max < GetQuantity())
10490 {
10491 split_quantity_new = GetQuantity() - stack_max;
10492 }
10493
10494 if (split_quantity_new == 0)
10495 {
10496 if (!GetGame().IsMultiplayer())
10497 player.PhysicalPredictiveDropItem(this);
10498 else
10499 player.ServerDropEntity(this);
10500 return;
10501 }
10502
10503 if (ShouldSplitQuantity(split_quantity_new))
10504 {
10505 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10506
10507 if (new_item)
10508 {
10509 new_item.SetResultOfSplit(true);
10510 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10511 SetQuantity(split_quantity_new, false, true);
10512 new_item.SetQuantity(stack_max, false, true);
10513 new_item.PlaceOnSurface();
10514 }
10515 }
10516 }
10517 }
10518 }
10519
10520 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10521 {
10522 float split_quantity_new;
10523 ItemBase new_item;
10524 float quantity = GetQuantity();
10525 float stack_max = GetTargetQuantityMax(slot_id);
10526 InventoryLocation loc = new InventoryLocation;
10527
10528 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10529 {
10530 if (stack_max <= GetQuantity())
10531 split_quantity_new = stack_max;
10532 else
10533 split_quantity_new = GetQuantity();
10534
10535 if (ShouldSplitQuantity(split_quantity_new))
10536 {
10537 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10538 if (new_item)
10539 {
10540 new_item.SetResultOfSplit(true);
10541 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10542 AddQuantity(-split_quantity_new, false, true);
10543 new_item.SetQuantity(split_quantity_new, false, true);
10544 }
10545 }
10546 }
10547 else if (destination_entity && slot_id == -1)
10548 {
10549 if (quantity > stack_max)
10550 split_quantity_new = stack_max;
10551 else
10552 split_quantity_new = quantity;
10553
10554 if (ShouldSplitQuantity(split_quantity_new))
10555 {
10556 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10557 {
10558 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10559 new_item = ItemBase.Cast(o);
10560 }
10561
10562 if (new_item)
10563 {
10564 new_item.SetResultOfSplit(true);
10565 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10566 AddQuantity(-split_quantity_new, false, true);
10567 new_item.SetQuantity(split_quantity_new, false, true);
10568 }
10569 }
10570 }
10571 else
10572 {
10573 if (stack_max != 0)
10574 {
10575 if (stack_max < GetQuantity())
10576 {
10577 split_quantity_new = GetQuantity() - stack_max;
10578 }
10579
10580 if (ShouldSplitQuantity(split_quantity_new))
10581 {
10582 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10583
10584 if (new_item)
10585 {
10586 new_item.SetResultOfSplit(true);
10587 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10588 SetQuantity(split_quantity_new, false, true);
10589 new_item.SetQuantity(stack_max, false, true);
10590 new_item.PlaceOnSurface();
10591 }
10592 }
10593 }
10594 }
10595 }
10596
10597 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10598 {
10599 if (GetGame().IsClient())
10600 {
10601 if (ScriptInputUserData.CanStoreInputUserData())
10602 {
10603 ScriptInputUserData ctx = new ScriptInputUserData;
10605 ctx.Write(4);
10606 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10607 ctx.Write(thiz);
10608 dst.WriteToContext(ctx);
10609 ctx.Send();
10610 }
10611 }
10612 else if (!GetGame().IsMultiplayer())
10613 {
10615 }
10616 }
10617
10618 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10619 {
10620 if (GetGame().IsClient())
10621 {
10622 if (ScriptInputUserData.CanStoreInputUserData())
10623 {
10624 ScriptInputUserData ctx = new ScriptInputUserData;
10626 ctx.Write(2);
10627 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10628 ctx.Write(dummy);
10629 ctx.Write(destination_entity);
10630 ctx.Write(true);
10631 ctx.Write(idx);
10632 ctx.Write(row);
10633 ctx.Write(col);
10634 ctx.Send();
10635 }
10636 }
10637 else if (!GetGame().IsMultiplayer())
10638 {
10639 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10640 }
10641 }
10642
10643 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10644 {
10646 }
10647
10648 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10649 {
10650 float quantity = GetQuantity();
10651 float split_quantity_new;
10652 ItemBase new_item;
10653 if (dst.IsValid())
10654 {
10655 int slot_id = dst.GetSlot();
10656 float stack_max = GetTargetQuantityMax(slot_id);
10657
10658 if (quantity > stack_max)
10659 split_quantity_new = stack_max;
10660 else
10661 split_quantity_new = quantity;
10662
10663 if (ShouldSplitQuantity(split_quantity_new))
10664 {
10665 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10666
10667 if (new_item)
10668 {
10669 new_item.SetResultOfSplit(true);
10670 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10671 AddQuantity(-split_quantity_new, false, true);
10672 new_item.SetQuantity(split_quantity_new, false, true);
10673 }
10674
10675 return new_item;
10676 }
10677 }
10678
10679 return null;
10680 }
10681
10682 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10683 {
10684 float quantity = GetQuantity();
10685 float split_quantity_new;
10686 ItemBase new_item;
10687 if (destination_entity)
10688 {
10689 float stackable = GetTargetQuantityMax();
10690 if (quantity > stackable)
10691 split_quantity_new = stackable;
10692 else
10693 split_quantity_new = quantity;
10694
10695 if (ShouldSplitQuantity(split_quantity_new))
10696 {
10697 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10698 if (new_item)
10699 {
10700 new_item.SetResultOfSplit(true);
10701 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10702 AddQuantity(-split_quantity_new, false, true);
10703 new_item.SetQuantity(split_quantity_new, false, true);
10704 }
10705 }
10706 }
10707 }
10708
10709 void SplitIntoStackMaxHandsClient(PlayerBase player)
10710 {
10711 if (GetGame().IsClient())
10712 {
10713 if (ScriptInputUserData.CanStoreInputUserData())
10714 {
10715 ScriptInputUserData ctx = new ScriptInputUserData;
10717 ctx.Write(3);
10718 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10719 ctx.Write(i1);
10720 ItemBase destination_entity = this;
10721 ctx.Write(destination_entity);
10722 ctx.Write(true);
10723 ctx.Write(0);
10724 ctx.Send();
10725 }
10726 }
10727 else if (!GetGame().IsMultiplayer())
10728 {
10729 SplitIntoStackMaxHands(player);
10730 }
10731 }
10732
10733 void SplitIntoStackMaxHands(PlayerBase player)
10734 {
10735 float quantity = GetQuantity();
10736 float split_quantity_new;
10737 ref ItemBase new_item;
10738 if (player)
10739 {
10740 float stackable = GetTargetQuantityMax();
10741 if (quantity > stackable)
10742 split_quantity_new = stackable;
10743 else
10744 split_quantity_new = quantity;
10745
10746 if (ShouldSplitQuantity(split_quantity_new))
10747 {
10748 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10749 new_item = ItemBase.Cast(in_hands);
10750 if (new_item)
10751 {
10752 new_item.SetResultOfSplit(true);
10753 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10754 AddQuantity(-split_quantity_new, false, true);
10755 new_item.SetQuantity(split_quantity_new, false, true);
10756 }
10757 }
10758 }
10759 }
10760
10761 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10762 {
10763 float quantity = GetQuantity();
10764 float split_quantity_new = Math.Floor(quantity * 0.5);
10765
10766 if (!ShouldSplitQuantity(split_quantity_new))
10767 return;
10768
10769 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10770
10771 if (new_item)
10772 {
10773 if (new_item.GetQuantityMax() < split_quantity_new)
10774 {
10775 split_quantity_new = new_item.GetQuantityMax();
10776 }
10777
10778 new_item.SetResultOfSplit(true);
10779 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10780
10781 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10782 {
10783 AddQuantity(-1, false, true);
10784 new_item.SetQuantity(1, false, true);
10785 }
10786 else
10787 {
10788 AddQuantity(-split_quantity_new, false, true);
10789 new_item.SetQuantity(split_quantity_new, false, true);
10790 }
10791 }
10792 }
10793
10794 void SplitItem(PlayerBase player)
10795 {
10796 float quantity = GetQuantity();
10797 float split_quantity_new = Math.Floor(quantity / 2);
10798
10799 if (!ShouldSplitQuantity(split_quantity_new))
10800 return;
10801
10802 InventoryLocation invloc = new InventoryLocation;
10803 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10804
10805 ItemBase new_item;
10806 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10807
10808 if (new_item)
10809 {
10810 if (new_item.GetQuantityMax() < split_quantity_new)
10811 {
10812 split_quantity_new = new_item.GetQuantityMax();
10813 }
10814 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10815 {
10816 AddQuantity(-1, false, true);
10817 new_item.SetQuantity(1, false, true);
10818 }
10819 else if (split_quantity_new > 1)
10820 {
10821 AddQuantity(-split_quantity_new, false, true);
10822 new_item.SetQuantity(split_quantity_new, false, true);
10823 }
10824 }
10825 }
10826
10828 void OnQuantityChanged(float delta)
10829 {
10830 SetWeightDirty();
10831 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10832
10833 if (parent)
10834 parent.OnAttachmentQuantityChangedEx(this, delta);
10835
10836 if (IsLiquidContainer())
10837 {
10838 if (GetQuantityNormalized() <= 0.0)
10839 {
10841 }
10842 else if (GetLiquidType() == LIQUID_NONE)
10843 {
10844 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10846 }
10847 }
10848
10849 }
10850
10853 {
10854 // insert code here
10855 }
10856
10858 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10859 {
10861 }
10862
10863 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10864 {
10865 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10866
10867 if (GetGame().IsServer())
10868 {
10869 if (newLevel == GameConstants.STATE_RUINED)
10870 {
10872 EntityAI parent = GetHierarchyParent();
10873 if (parent && parent.IsFireplace())
10874 {
10875 CargoBase cargo = GetInventory().GetCargo();
10876 if (cargo)
10877 {
10878 for (int i = 0; i < cargo.GetItemCount(); ++i)
10879 {
10880 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10881 }
10882 }
10883 }
10884 }
10885
10886 if (IsResultOfSplit())
10887 {
10888 // reset the splitting result flag, return to normal item behavior
10889 SetResultOfSplit(false);
10890 return;
10891 }
10892
10893 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10894 {
10895 SetCleanness(0);//unclean the item upon damage dealt
10896 }
10897 }
10898 }
10899
10900 // just the split? TODO: verify
10901 override void OnRightClick()
10902 {
10903 super.OnRightClick();
10904
10905 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
10906 {
10907 if (GetGame().IsClient())
10908 {
10909 if (ScriptInputUserData.CanStoreInputUserData())
10910 {
10911 EntityAI root = GetHierarchyRoot();
10912 Man playerOwner = GetHierarchyRootPlayer();
10913 InventoryLocation dst = new InventoryLocation;
10914
10915 // 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
10916 if (!playerOwner && root && root == this)
10917 {
10919 }
10920 else
10921 {
10922 // 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
10923 GetInventory().GetCurrentInventoryLocation(dst);
10924 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10925 {
10926 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
10927 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10928 {
10930 }
10931 else
10932 {
10933 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10934 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10935 this shouldnt cause issues within this scope*/
10936 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10937 {
10939 }
10940 else
10941 {
10942 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10943 }
10944 }
10945 }
10946 }
10947
10948 ScriptInputUserData ctx = new ScriptInputUserData;
10950 ctx.Write(4);
10951 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10952 ctx.Write(thiz);
10953 dst.WriteToContext(ctx);
10954 ctx.Write(true); // dummy
10955 ctx.Send();
10956 }
10957 }
10958 else if (!GetGame().IsMultiplayer())
10959 {
10960 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
10961 }
10962 }
10963 }
10964
10965 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10966 {
10967 if (root)
10968 {
10969 vector m4[4];
10970 root.GetTransform(m4);
10971 dst.SetGround(this, m4);
10972 }
10973 else
10974 {
10975 GetInventory().GetCurrentInventoryLocation(dst);
10976 }
10977 }
10978
10979 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10980 {
10981 //TODO: delete check zero quantity check after fix double posts hands fsm events
10982 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10983 return false;
10984
10985 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10986 return false;
10987
10988 //can_this_be_combined = ConfigGetBool("canBeSplit");
10990 return false;
10991
10992
10993 Magazine mag = Magazine.Cast(this);
10994 if (mag)
10995 {
10996 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10997 return false;
10998
10999 if (stack_max_limit)
11000 {
11001 Magazine other_mag = Magazine.Cast(other_item);
11002 if (other_item)
11003 {
11004 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
11005 return false;
11006 }
11007
11008 }
11009 }
11010 else
11011 {
11012 //TODO: delete check zero quantity check after fix double posts hands fsm events
11013 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
11014 return false;
11015
11016 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
11017 return false;
11018 }
11019
11020 PlayerBase player = null;
11021 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
11022 {
11023 if (player.GetInventory().HasAttachment(this))
11024 return false;
11025
11026 if (player.IsItemsToDelete())
11027 return false;
11028 }
11029
11030 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
11031 return false;
11032
11033 int slotID;
11034 string slotName;
11035 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
11036 return false;
11037
11038 return true;
11039 }
11040
11041 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
11042 {
11043 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
11044 }
11045
11046 bool IsResultOfSplit()
11047 {
11048 return m_IsResultOfSplit;
11049 }
11050
11051 void SetResultOfSplit(bool value)
11052 {
11053 m_IsResultOfSplit = value;
11054 }
11055
11056 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
11057 {
11058 return ComputeQuantityUsedEx(other_item, use_stack_max);
11059 }
11060
11061 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
11062 {
11063 float other_item_quantity = other_item.GetQuantity();
11064 float this_free_space;
11065
11066 float stack_max = GetQuantityMax();
11067
11068 this_free_space = stack_max - GetQuantity();
11069
11070 if (other_item_quantity > this_free_space)
11071 {
11072 return this_free_space;
11073 }
11074 else
11075 {
11076 return other_item_quantity;
11077 }
11078 }
11079
11080 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
11081 {
11082 CombineItems(ItemBase.Cast(entity2),use_stack_max);
11083 }
11084
11085 void CombineItems(ItemBase other_item, bool use_stack_max = true)
11086 {
11087 if (!CanBeCombined(other_item, false))
11088 return;
11089
11090 if (!IsMagazine() && other_item)
11091 {
11092 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
11093 if (quantity_used != 0)
11094 {
11095 float hp1 = GetHealth01("","");
11096 float hp2 = other_item.GetHealth01("","");
11097 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
11098 hpResult = hpResult / (GetQuantity() + quantity_used);
11099
11100 hpResult *= GetMaxHealth();
11101 Math.Round(hpResult);
11102 SetHealth("", "Health", hpResult);
11103
11104 AddQuantity(quantity_used);
11105 other_item.AddQuantity(-quantity_used);
11106 }
11107 }
11108 OnCombine(other_item);
11109 }
11110
11111 void OnCombine(ItemBase other_item)
11112 {
11113 #ifdef SERVER
11114 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11115 GetHierarchyParent().IncreaseLifetimeUp();
11116 #endif
11117 };
11118
11119 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11120 {
11121 PlayerBase p = PlayerBase.Cast(player);
11122
11123 array<int> recipesIds = p.m_Recipes;
11124 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11125 if (moduleRecipesManager)
11126 {
11127 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
11128 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11129 }
11130
11131 for (int i = 0;i < recipesIds.Count(); i++)
11132 {
11133 int key = recipesIds.Get(i);
11134 string recipeName = moduleRecipesManager.GetRecipeName(key);
11135 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11136 }
11137 }
11138
11139 // -------------------------------------------------------------------------
11140 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11141 {
11142 super.GetDebugActions(outputList);
11143
11144 //quantity
11145 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11146 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11147 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11148 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11149 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11150
11151 //health
11152 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
11153 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
11154 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
11155 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11156 //temperature
11157 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
11158 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
11159 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
11160 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11161
11162 //wet
11163 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
11164 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
11165 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11166
11167 //liquidtype
11168 if (IsLiquidContainer())
11169 {
11170 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
11171 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
11172 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11173 }
11174
11175 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
11176 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11177
11178 // watch
11179 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
11180 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
11181 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11182
11183 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
11184
11185 InventoryLocation loc = new InventoryLocation();
11186 GetInventory().GetCurrentInventoryLocation(loc);
11187 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11188 {
11189 if (Gizmo_IsSupported())
11190 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11191 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11192 }
11193
11194 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11195 }
11196
11197 // -------------------------------------------------------------------------
11198 // -------------------------------------------------------------------------
11199 // -------------------------------------------------------------------------
11200 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11201 {
11202 super.OnAction(action_id, player, ctx);
11203
11204 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
11205 {
11206 switch (action_id)
11207 {
11208 case EActions.GIZMO_OBJECT:
11209 GetGame().GizmoSelectObject(this);
11210 return true;
11211 case EActions.GIZMO_PHYSICS:
11212 GetGame().GizmoSelectPhysics(GetPhysics());
11213 return true;
11214 }
11215 }
11216
11217 if (GetGame().IsServer())
11218 {
11219 switch (action_id)
11220 {
11221 case EActions.DELETE:
11222 Delete();
11223 return true;
11224 }
11225 }
11226
11227 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11228 {
11229 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11230 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11231 PlayerBase p = PlayerBase.Cast(player);
11232 if (EActions.RECIPES_RANGE_START < 1000)
11233 {
11234 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11235 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11236 }
11237 }
11238 #ifndef SERVER
11239 else if (action_id == EActions.WATCH_PLAYER)
11240 {
11241 PluginDeveloper.SetDeveloperItemClientEx(player);
11242 }
11243 #endif
11244 if (GetGame().IsServer())
11245 {
11246 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11247 {
11248 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11249 OnDebugButtonPressServer(id + 1);
11250 }
11251
11252 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11253 {
11254 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11255 InsertAgent(agent_id,100);
11256 }
11257
11258 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11259 {
11260 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11261 RemoveAgent(agent_id2);
11262 }
11263
11264 else if (action_id == EActions.ADD_QUANTITY)
11265 {
11266 if (IsMagazine())
11267 {
11268 Magazine mag = Magazine.Cast(this);
11269 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11270 }
11271 else
11272 {
11273 AddQuantity(GetQuantityMax() * 0.2);
11274 }
11275
11276 if (m_EM)
11277 {
11278 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11279 }
11280 //PrintVariables();
11281 }
11282
11283 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11284 {
11285 if (IsMagazine())
11286 {
11287 Magazine mag2 = Magazine.Cast(this);
11288 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11289 }
11290 else
11291 {
11292 AddQuantity(- GetQuantityMax() * 0.2);
11293 }
11294 if (m_EM)
11295 {
11296 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11297 }
11298 //PrintVariables();
11299 }
11300
11301 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11302 {
11303 SetQuantity(0);
11304
11305 if (m_EM)
11306 {
11307 m_EM.SetEnergy(0);
11308 }
11309 }
11310
11311 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11312 {
11314
11315 if (m_EM)
11316 {
11317 m_EM.SetEnergy(m_EM.GetEnergyMax());
11318 }
11319 }
11320
11321 else if (action_id == EActions.ADD_HEALTH)
11322 {
11323 AddHealth("","",GetMaxHealth("","Health")/5);
11324 }
11325 else if (action_id == EActions.REMOVE_HEALTH)
11326 {
11327 AddHealth("","",-GetMaxHealth("","Health")/5);
11328 }
11329 else if (action_id == EActions.DESTROY_HEALTH)
11330 {
11331 SetHealth01("","",0);
11332 }
11333 else if (action_id == EActions.WATCH_ITEM)
11334 {
11336 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11337 #ifdef DEVELOPER
11338 SetDebugDeveloper_item(this);
11339 #endif
11340 }
11341
11342 else if (action_id == EActions.ADD_TEMPERATURE)
11343 {
11344 AddTemperature(20);
11345 //PrintVariables();
11346 }
11347
11348 else if (action_id == EActions.REMOVE_TEMPERATURE)
11349 {
11350 AddTemperature(-20);
11351 //PrintVariables();
11352 }
11353
11354 else if (action_id == EActions.FLIP_FROZEN)
11355 {
11356 SetFrozen(!GetIsFrozen());
11357 //PrintVariables();
11358 }
11359
11360 else if (action_id == EActions.ADD_WETNESS)
11361 {
11362 AddWet(GetWetMax()/5);
11363 //PrintVariables();
11364 }
11365
11366 else if (action_id == EActions.REMOVE_WETNESS)
11367 {
11368 AddWet(-GetWetMax()/5);
11369 //PrintVariables();
11370 }
11371
11372 else if (action_id == EActions.LIQUIDTYPE_UP)
11373 {
11374 int curr_type = GetLiquidType();
11375 SetLiquidType(curr_type * 2);
11376 //AddWet(1);
11377 //PrintVariables();
11378 }
11379
11380 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11381 {
11382 int curr_type2 = GetLiquidType();
11383 SetLiquidType(curr_type2 / 2);
11384 }
11385
11386 else if (action_id == EActions.MAKE_SPECIAL)
11387 {
11388 auto debugParams = DebugSpawnParams.WithPlayer(player);
11389 OnDebugSpawnEx(debugParams);
11390 }
11391
11392 }
11393
11394
11395 return false;
11396 }
11397
11398 // -------------------------------------------------------------------------
11399
11400
11403 void OnActivatedByTripWire();
11404
11406 void OnActivatedByItem(notnull ItemBase item);
11407
11408 //----------------------------------------------------------------
11409 //returns true if item is able to explode when put in fire
11410 bool CanExplodeInFire()
11411 {
11412 return false;
11413 }
11414
11415 //----------------------------------------------------------------
11416 bool CanEat()
11417 {
11418 return true;
11419 }
11420
11421 //----------------------------------------------------------------
11422 override bool IsIgnoredByConstruction()
11423 {
11424 return true;
11425 }
11426
11427 //----------------------------------------------------------------
11428 //has FoodStages in config?
11429 bool HasFoodStage()
11430 {
11431 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11432 return GetGame().ConfigIsExisting(config_path);
11433 }
11434
11436 FoodStage GetFoodStage()
11437 {
11438 return null;
11439 }
11440
11441 bool CanBeCooked()
11442 {
11443 return false;
11444 }
11445
11446 bool CanBeCookedOnStick()
11447 {
11448 return false;
11449 }
11450
11452 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11454
11455 //----------------------------------------------------------------
11456 bool CanRepair(ItemBase item_repair_kit)
11457 {
11458 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11459 return module_repairing.CanRepair(this, item_repair_kit);
11460 }
11461
11462 //----------------------------------------------------------------
11463 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11464 {
11465 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11466 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11467 }
11468
11469 //----------------------------------------------------------------
11470 int GetItemSize()
11471 {
11472 /*
11473 vector v_size = this.ConfigGetVector("itemSize");
11474 int v_size_x = v_size[0];
11475 int v_size_y = v_size[1];
11476 int size = v_size_x * v_size_y;
11477 return size;
11478 */
11479
11480 return 1;
11481 }
11482
11483 //----------------------------------------------------------------
11484 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11485 bool CanBeMovedOverride()
11486 {
11487 return m_CanBeMovedOverride;
11488 }
11489
11490 //----------------------------------------------------------------
11491 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11492 void SetCanBeMovedOverride(bool setting)
11493 {
11494 m_CanBeMovedOverride = setting;
11495 }
11496
11497 //----------------------------------------------------------------
11505 void MessageToOwnerStatus(string text)
11506 {
11507 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11508
11509 if (player)
11510 {
11511 player.MessageStatus(text);
11512 }
11513 }
11514
11515 //----------------------------------------------------------------
11523 void MessageToOwnerAction(string text)
11524 {
11525 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11526
11527 if (player)
11528 {
11529 player.MessageAction(text);
11530 }
11531 }
11532
11533 //----------------------------------------------------------------
11541 void MessageToOwnerFriendly(string text)
11542 {
11543 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11544
11545 if (player)
11546 {
11547 player.MessageFriendly(text);
11548 }
11549 }
11550
11551 //----------------------------------------------------------------
11559 void MessageToOwnerImportant(string text)
11560 {
11561 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11562
11563 if (player)
11564 {
11565 player.MessageImportant(text);
11566 }
11567 }
11568
11569 override bool IsItemBase()
11570 {
11571 return true;
11572 }
11573
11574 // Checks if item is of questioned kind
11575 override bool KindOf(string tag)
11576 {
11577 bool found = false;
11578 string item_name = this.GetType();
11579 ref TStringArray item_tag_array = new TStringArray;
11580 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11581
11582 int array_size = item_tag_array.Count();
11583 for (int i = 0; i < array_size; i++)
11584 {
11585 if (item_tag_array.Get(i) == tag)
11586 {
11587 found = true;
11588 break;
11589 }
11590 }
11591 return found;
11592 }
11593
11594
11595 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11596 {
11597 //Debug.Log("OnRPC called");
11598 super.OnRPC(sender, rpc_type,ctx);
11599
11600 //Play soundset for attachment locking (ActionLockAttachment.c)
11601 switch (rpc_type)
11602 {
11603 #ifndef SERVER
11604 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11605 Param2<bool, string> p = new Param2<bool, string>(false, "");
11606
11607 if (!ctx.Read(p))
11608 return;
11609
11610 bool play = p.param1;
11611 string soundSet = p.param2;
11612
11613 if (play)
11614 {
11615 if (m_LockingSound)
11616 {
11618 {
11619 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11620 }
11621 }
11622 else
11623 {
11624 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11625 }
11626 }
11627 else
11628 {
11629 SEffectManager.DestroyEffect(m_LockingSound);
11630 }
11631
11632 break;
11633 #endif
11634
11635 }
11636
11637 if (GetWrittenNoteData())
11638 {
11639 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11640 }
11641 }
11642
11643 //-----------------------------
11644 // VARIABLE MANIPULATION SYSTEM
11645 //-----------------------------
11646 int NameToID(string name)
11647 {
11648 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11649 return plugin.GetID(name);
11650 }
11651
11652 string IDToName(int id)
11653 {
11654 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11655 return plugin.GetName(id);
11656 }
11657
11659 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11660 {
11661 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11662 //read the flags
11663 int varFlags;
11664 if (!ctx.Read(varFlags))
11665 return;
11666
11667 if (varFlags & ItemVariableFlags.FLOAT)
11668 {
11669 ReadVarsFromCTX(ctx);
11670 }
11671 }
11672
11673 override void SerializeNumericalVars(array<float> floats_out)
11674 {
11675 //some variables handled on EntityAI level already!
11676 super.SerializeNumericalVars(floats_out);
11677
11678 // the order of serialization must be the same as the order of de-serialization
11679 //--------------------------------------------
11680 if (IsVariableSet(VARIABLE_QUANTITY))
11681 {
11682 floats_out.Insert(m_VarQuantity);
11683 }
11684 //--------------------------------------------
11685 if (IsVariableSet(VARIABLE_WET))
11686 {
11687 floats_out.Insert(m_VarWet);
11688 }
11689 //--------------------------------------------
11690 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11691 {
11692 floats_out.Insert(m_VarLiquidType);
11693 }
11694 //--------------------------------------------
11695 if (IsVariableSet(VARIABLE_COLOR))
11696 {
11697 floats_out.Insert(m_ColorComponentR);
11698 floats_out.Insert(m_ColorComponentG);
11699 floats_out.Insert(m_ColorComponentB);
11700 floats_out.Insert(m_ColorComponentA);
11701 }
11702 //--------------------------------------------
11703 if (IsVariableSet(VARIABLE_CLEANNESS))
11704 {
11705 floats_out.Insert(m_Cleanness);
11706 }
11707 }
11708
11709 override void DeSerializeNumericalVars(array<float> floats)
11710 {
11711 //some variables handled on EntityAI level already!
11712 super.DeSerializeNumericalVars(floats);
11713
11714 // the order of serialization must be the same as the order of de-serialization
11715 int index = 0;
11716 int mask = Math.Round(floats.Get(index));
11717
11718 index++;
11719 //--------------------------------------------
11720 if (mask & VARIABLE_QUANTITY)
11721 {
11722 if (m_IsStoreLoad)
11723 {
11724 SetStoreLoadedQuantity(floats.Get(index));
11725 }
11726 else
11727 {
11728 float quantity = floats.Get(index);
11729 SetQuantity(quantity, true, false, false, false);
11730 }
11731 index++;
11732 }
11733 //--------------------------------------------
11734 if (mask & VARIABLE_WET)
11735 {
11736 float wet = floats.Get(index);
11737 SetWet(wet);
11738 index++;
11739 }
11740 //--------------------------------------------
11741 if (mask & VARIABLE_LIQUIDTYPE)
11742 {
11743 int liquidtype = Math.Round(floats.Get(index));
11744 SetLiquidType(liquidtype);
11745 index++;
11746 }
11747 //--------------------------------------------
11748 if (mask & VARIABLE_COLOR)
11749 {
11750 m_ColorComponentR = Math.Round(floats.Get(index));
11751 index++;
11752 m_ColorComponentG = Math.Round(floats.Get(index));
11753 index++;
11754 m_ColorComponentB = Math.Round(floats.Get(index));
11755 index++;
11756 m_ColorComponentA = Math.Round(floats.Get(index));
11757 index++;
11758 }
11759 //--------------------------------------------
11760 if (mask & VARIABLE_CLEANNESS)
11761 {
11762 int cleanness = Math.Round(floats.Get(index));
11763 SetCleanness(cleanness);
11764 index++;
11765 }
11766 }
11767
11768 override void WriteVarsToCTX(ParamsWriteContext ctx)
11769 {
11770 super.WriteVarsToCTX(ctx);
11771
11772 //--------------------------------------------
11773 if (IsVariableSet(VARIABLE_QUANTITY))
11774 {
11775 ctx.Write(GetQuantity());
11776 }
11777 //--------------------------------------------
11778 if (IsVariableSet(VARIABLE_WET))
11779 {
11780 ctx.Write(GetWet());
11781 }
11782 //--------------------------------------------
11783 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11784 {
11785 ctx.Write(GetLiquidType());
11786 }
11787 //--------------------------------------------
11788 if (IsVariableSet(VARIABLE_COLOR))
11789 {
11790 int r,g,b,a;
11791 GetColor(r,g,b,a);
11792 ctx.Write(r);
11793 ctx.Write(g);
11794 ctx.Write(b);
11795 ctx.Write(a);
11796 }
11797 //--------------------------------------------
11798 if (IsVariableSet(VARIABLE_CLEANNESS))
11799 {
11800 ctx.Write(GetCleanness());
11801 }
11802 }
11803
11804 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11805 {
11806 if (!super.ReadVarsFromCTX(ctx,version))
11807 return false;
11808
11809 int intValue;
11810 float value;
11811
11812 if (version < 140)
11813 {
11814 if (!ctx.Read(intValue))
11815 return false;
11816
11817 m_VariablesMask = intValue;
11818 }
11819
11820 if (m_VariablesMask & VARIABLE_QUANTITY)
11821 {
11822 if (!ctx.Read(value))
11823 return false;
11824
11825 if (IsStoreLoad())
11826 {
11828 }
11829 else
11830 {
11831 SetQuantity(value, true, false, false, false);
11832 }
11833 }
11834 //--------------------------------------------
11835 if (version < 140)
11836 {
11837 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11838 {
11839 if (!ctx.Read(value))
11840 return false;
11841 SetTemperatureDirect(value);
11842 }
11843 }
11844 //--------------------------------------------
11845 if (m_VariablesMask & VARIABLE_WET)
11846 {
11847 if (!ctx.Read(value))
11848 return false;
11849 SetWet(value);
11850 }
11851 //--------------------------------------------
11852 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11853 {
11854 if (!ctx.Read(intValue))
11855 return false;
11856 SetLiquidType(intValue);
11857 }
11858 //--------------------------------------------
11859 if (m_VariablesMask & VARIABLE_COLOR)
11860 {
11861 int r,g,b,a;
11862 if (!ctx.Read(r))
11863 return false;
11864 if (!ctx.Read(g))
11865 return false;
11866 if (!ctx.Read(b))
11867 return false;
11868 if (!ctx.Read(a))
11869 return false;
11870
11871 SetColor(r,g,b,a);
11872 }
11873 //--------------------------------------------
11874 if (m_VariablesMask & VARIABLE_CLEANNESS)
11875 {
11876 if (!ctx.Read(intValue))
11877 return false;
11878 SetCleanness(intValue);
11879 }
11880 //--------------------------------------------
11881 if (version >= 138 && version < 140)
11882 {
11883 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11884 {
11885 if (!ctx.Read(intValue))
11886 return false;
11887 SetFrozen(intValue);
11888 }
11889 }
11890
11891 return true;
11892 }
11893
11894 //----------------------------------------------------------------
11895 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11896 {
11897 m_IsStoreLoad = true;
11899 {
11900 m_FixDamageSystemInit = true;
11901 }
11902
11903 if (!super.OnStoreLoad(ctx, version))
11904 {
11905 m_IsStoreLoad = false;
11906 return false;
11907 }
11908
11909 if (version >= 114)
11910 {
11911 bool hasQuickBarIndexSaved;
11912
11913 if (!ctx.Read(hasQuickBarIndexSaved))
11914 {
11915 m_IsStoreLoad = false;
11916 return false;
11917 }
11918
11919 if (hasQuickBarIndexSaved)
11920 {
11921 int itmQBIndex;
11922
11923 //Load quickbar item bind
11924 if (!ctx.Read(itmQBIndex))
11925 {
11926 m_IsStoreLoad = false;
11927 return false;
11928 }
11929
11930 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11931 if (itmQBIndex != -1 && parentPlayer)
11932 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11933 }
11934 }
11935 else
11936 {
11937 // Backup of how it used to be
11938 PlayerBase player;
11939 int itemQBIndex;
11940 if (version == int.MAX)
11941 {
11942 if (!ctx.Read(itemQBIndex))
11943 {
11944 m_IsStoreLoad = false;
11945 return false;
11946 }
11947 }
11948 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11949 {
11950 //Load quickbar item bind
11951 if (!ctx.Read(itemQBIndex))
11952 {
11953 m_IsStoreLoad = false;
11954 return false;
11955 }
11956 if (itemQBIndex != -1 && player)
11957 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11958 }
11959 }
11960
11961 if (version < 140)
11962 {
11963 // variable management system
11964 if (!LoadVariables(ctx, version))
11965 {
11966 m_IsStoreLoad = false;
11967 return false;
11968 }
11969 }
11970
11971 //agent trasmission system
11972 if (!LoadAgents(ctx, version))
11973 {
11974 m_IsStoreLoad = false;
11975 return false;
11976 }
11977 if (version >= 132)
11978 {
11979 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11980 if (raib)
11981 {
11982 if (!raib.OnStoreLoad(ctx,version))
11983 {
11984 m_IsStoreLoad = false;
11985 return false;
11986 }
11987 }
11988 }
11989
11990 m_IsStoreLoad = false;
11991 return true;
11992 }
11993
11994 //----------------------------------------------------------------
11995
11996 override void OnStoreSave(ParamsWriteContext ctx)
11997 {
11998 super.OnStoreSave(ctx);
11999
12000 PlayerBase player;
12001 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
12002 {
12003 ctx.Write(true); // Keep track of if we should actually read this in or not
12004 //Save quickbar item bind
12005 int itemQBIndex = -1;
12006 itemQBIndex = player.FindQuickBarEntityIndex(this);
12007 ctx.Write(itemQBIndex);
12008 }
12009 else
12010 {
12011 ctx.Write(false); // Keep track of if we should actually read this in or not
12012 }
12013
12014 SaveAgents(ctx);//agent trasmission system
12015
12016 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12017 if (raib)
12018 {
12019 raib.OnStoreSave(ctx);
12020 }
12021 }
12022 //----------------------------------------------------------------
12023
12024 override void AfterStoreLoad()
12025 {
12026 super.AfterStoreLoad();
12027
12029 {
12031 }
12032
12033 if (GetStoreLoadedQuantity() != float.LOWEST)
12034 {
12036 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
12037 }
12038 }
12039
12040 override void EEOnAfterLoad()
12041 {
12042 super.EEOnAfterLoad();
12043
12045 {
12046 m_FixDamageSystemInit = false;
12047 }
12048
12051 }
12052
12053 bool CanBeDisinfected()
12054 {
12055 return false;
12056 }
12057
12058
12059 //----------------------------------------------------------------
12060 override void OnVariablesSynchronized()
12061 {
12062 if (m_Initialized)
12063 {
12064 #ifdef PLATFORM_CONSOLE
12065 //bruteforce it is
12066 if (IsSplitable())
12067 {
12068 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
12069 if (menu)
12070 {
12071 menu.Refresh();
12072 }
12073 }
12074 #endif
12075 }
12076
12078 {
12079 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
12080 m_WantPlayImpactSound = false;
12081 }
12082
12084 {
12085 SetWeightDirty();
12087 }
12088 if (m_VarWet != m_VarWetPrev)
12089 {
12092 }
12093
12094 if (m_SoundSyncPlay != 0)
12095 {
12096 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
12097 m_SoundSyncPlay = 0;
12098 }
12099 if (m_SoundSyncStop != 0)
12100 {
12101 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12102 m_SoundSyncStop = 0;
12103 }
12104
12105 super.OnVariablesSynchronized();
12106 }
12107
12108 //------------------------- Quantity
12109 //----------------------------------------------------------------
12111 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12112 {
12113 if (!IsServerCheck(allow_client))
12114 return false;
12115
12116 if (!HasQuantity())
12117 return false;
12118
12119 float min = GetQuantityMin();
12120 float max = GetQuantityMax();
12121
12122 if (value <= (min + 0.001))
12123 value = min;
12124
12125 if (value == min)
12126 {
12127 if (destroy_config)
12128 {
12129 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12130 if (dstr)
12131 {
12132 m_VarQuantity = Math.Clamp(value, min, max);
12133 this.Delete();
12134 return true;
12135 }
12136 }
12137 else if (destroy_forced)
12138 {
12139 m_VarQuantity = Math.Clamp(value, min, max);
12140 this.Delete();
12141 return true;
12142 }
12143 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12144 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12145 }
12146
12147 float delta = m_VarQuantity;
12148 m_VarQuantity = Math.Clamp(value, min, max);
12149
12150 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
12151 {
12152 delta = m_VarQuantity - delta;
12153
12154 if (delta)
12155 OnQuantityChanged(delta);
12156 }
12157
12158 SetVariableMask(VARIABLE_QUANTITY);
12159
12160 return false;
12161 }
12162
12163 //----------------------------------------------------------------
12165 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
12166 {
12167 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
12168 }
12169 //----------------------------------------------------------------
12170 void SetQuantityMax()
12171 {
12172 float max = GetQuantityMax();
12173 SetQuantity(max);
12174 }
12175
12176 override void SetQuantityToMinimum()
12177 {
12178 float min = GetQuantityMin();
12179 SetQuantity(min);
12180 }
12181 //----------------------------------------------------------------
12183 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
12184 {
12185 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
12186 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
12187 SetQuantity(result, destroy_config, destroy_forced);
12188 }
12189
12190 //----------------------------------------------------------------
12192 override float GetQuantityNormalized()
12193 {
12194 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12195 }
12196
12198 {
12199 return GetQuantityNormalized();
12200 }
12201
12202 /*void SetAmmoNormalized(float value)
12203 {
12204 float value_clamped = Math.Clamp(value, 0, 1);
12205 Magazine this_mag = Magazine.Cast(this);
12206 int max_rounds = this_mag.GetAmmoMax();
12207 int result = value * max_rounds;//can the rounded if higher precision is required
12208 this_mag.SetAmmoCount(result);
12209 }*/
12210 //----------------------------------------------------------------
12211 override int GetQuantityMax()
12212 {
12213 int slot = -1;
12214 if (GetInventory())
12215 {
12216 InventoryLocation il = new InventoryLocation;
12217 GetInventory().GetCurrentInventoryLocation(il);
12218 slot = il.GetSlot();
12219 }
12220
12221 return GetTargetQuantityMax(slot);
12222 }
12223
12224 override int GetTargetQuantityMax(int attSlotID = -1)
12225 {
12226 float quantity_max = 0;
12227
12228 if (IsSplitable()) //only stackable/splitable items can check for stack size
12229 {
12230 if (attSlotID != -1)
12231 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12232
12233 if (quantity_max <= 0)
12234 quantity_max = m_VarStackMax;
12235 }
12236
12237 if (quantity_max <= 0)
12238 quantity_max = m_VarQuantityMax;
12239
12240 return quantity_max;
12241 }
12242 //----------------------------------------------------------------
12243 override int GetQuantityMin()
12244 {
12245 return m_VarQuantityMin;
12246 }
12247 //----------------------------------------------------------------
12248 int GetQuantityInit()
12249 {
12250 return m_VarQuantityInit;
12251 }
12252
12253 //----------------------------------------------------------------
12254 override bool HasQuantity()
12255 {
12256 return !(GetQuantityMax() - GetQuantityMin() == 0);
12257 }
12258
12259 override float GetQuantity()
12260 {
12261 return m_VarQuantity;
12262 }
12263
12264 bool IsFullQuantity()
12265 {
12266 return GetQuantity() >= GetQuantityMax();
12267 }
12268
12269 //Calculates weight of single item without attachments and cargo
12270 override float GetSingleInventoryItemWeightEx()
12271 {
12272 //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
12273 float weightEx = GetWeightEx();//overall weight of the item
12274 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12275 return weightEx - special;
12276 }
12277
12278 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12280 {
12282 }
12283
12284 override protected float GetWeightSpecialized(bool forceRecalc = false)
12285 {
12286 if (IsSplitable()) //quantity determines size of the stack
12287 {
12288 #ifdef DEVELOPER
12289 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12290 {
12291 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12292 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12293 }
12294 #endif
12295
12296 return GetQuantity() * GetConfigWeightModified();
12297 }
12298 else if (HasEnergyManager())// items with energy manager
12299 {
12300 #ifdef DEVELOPER
12301 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12302 {
12303 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12304 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12305 }
12306 #endif
12307 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12308 }
12309 else//everything else
12310 {
12311 #ifdef DEVELOPER
12312 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12313 {
12314 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12315 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12316 }
12317 #endif
12318 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12319 }
12320 }
12321
12323 int GetNumberOfItems()
12324 {
12325 int item_count = 0;
12326 ItemBase item;
12327
12328 if (GetInventory().GetCargo() != NULL)
12329 {
12330 item_count = GetInventory().GetCargo().GetItemCount();
12331 }
12332
12333 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
12334 {
12335 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
12336 if (item)
12337 item_count += item.GetNumberOfItems();
12338 }
12339 return item_count;
12340 }
12341
12343 float GetUnitWeight(bool include_wetness = true)
12344 {
12345 float weight = 0;
12346 float wetness = 1;
12347 if (include_wetness)
12348 wetness += GetWet();
12349 if (IsSplitable()) //quantity determines size of the stack
12350 {
12351 weight = wetness * m_ConfigWeight;
12352 }
12353 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12354 {
12355 weight = 1;
12356 }
12357 return weight;
12358 }
12359
12360 //-----------------------------------------------------------------
12361
12362 override void ClearInventory()
12363 {
12364 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
12365 {
12366 GameInventory inv = GetInventory();
12367 array<EntityAI> items = new array<EntityAI>;
12368 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
12369 for (int i = 0; i < items.Count(); i++)
12370 {
12371 ItemBase item = ItemBase.Cast(items.Get(i));
12372 if (item)
12373 {
12374 GetGame().ObjectDelete(item);
12375 }
12376 }
12377 }
12378 }
12379
12380 //------------------------- Energy
12381
12382 //----------------------------------------------------------------
12383 float GetEnergy()
12384 {
12385 float energy = 0;
12386 if (HasEnergyManager())
12387 {
12388 energy = GetCompEM().GetEnergy();
12389 }
12390 return energy;
12391 }
12392
12393
12394 override void OnEnergyConsumed()
12395 {
12396 super.OnEnergyConsumed();
12397
12399 }
12400
12401 override void OnEnergyAdded()
12402 {
12403 super.OnEnergyAdded();
12404
12406 }
12407
12408 // Converts energy (from Energy Manager) to quantity, if enabled.
12410 {
12411 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12412 {
12413 if (HasQuantity())
12414 {
12415 float energy_0to1 = GetCompEM().GetEnergy0To1();
12416 SetQuantityNormalized(energy_0to1);
12417 }
12418 }
12419 }
12420
12421 //----------------------------------------------------------------
12422 float GetHeatIsolationInit()
12423 {
12424 return ConfigGetFloat("heatIsolation");
12425 }
12426
12427 float GetHeatIsolation()
12428 {
12429 return m_HeatIsolation;
12430 }
12431
12432 float GetDryingIncrement(string pIncrementName)
12433 {
12434 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12435 if (GetGame().ConfigIsExisting(paramPath))
12436 return GetGame().ConfigGetFloat(paramPath);
12437
12438 return 0.0;
12439 }
12440
12441 float GetSoakingIncrement(string pIncrementName)
12442 {
12443 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12444 if (GetGame().ConfigIsExisting(paramPath))
12445 return GetGame().ConfigGetFloat(paramPath);
12446
12447 return 0.0;
12448 }
12449 //----------------------------------------------------------------
12450 override void SetWet(float value, bool allow_client = false)
12451 {
12452 if (!IsServerCheck(allow_client))
12453 return;
12454
12455 float min = GetWetMin();
12456 float max = GetWetMax();
12457
12458 float previousValue = m_VarWet;
12459
12460 m_VarWet = Math.Clamp(value, min, max);
12461
12462 if (previousValue != m_VarWet)
12463 {
12464 SetVariableMask(VARIABLE_WET);
12465 OnWetChanged(m_VarWet, previousValue);
12466 }
12467 }
12468 //----------------------------------------------------------------
12469 override void AddWet(float value)
12470 {
12471 SetWet(GetWet() + value);
12472 }
12473 //----------------------------------------------------------------
12474 override void SetWetMax()
12475 {
12477 }
12478 //----------------------------------------------------------------
12479 override float GetWet()
12480 {
12481 return m_VarWet;
12482 }
12483 //----------------------------------------------------------------
12484 override float GetWetMax()
12485 {
12486 return m_VarWetMax;
12487 }
12488 //----------------------------------------------------------------
12489 override float GetWetMin()
12490 {
12491 return m_VarWetMin;
12492 }
12493 //----------------------------------------------------------------
12494 override float GetWetInit()
12495 {
12496 return m_VarWetInit;
12497 }
12498 //----------------------------------------------------------------
12499 override void OnWetChanged(float newVal, float oldVal)
12500 {
12501 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12502 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12503 if (newLevel != oldLevel)
12504 {
12505 OnWetLevelChanged(newLevel,oldLevel);
12506 }
12507 }
12508
12509 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12510 {
12511 SetWeightDirty();
12512 }
12513
12514 override EWetnessLevel GetWetLevel()
12515 {
12516 return GetWetLevelInternal(m_VarWet);
12517 }
12518
12519 //----------------------------------------------------------------
12520
12521 override void SetStoreLoad(bool value)
12522 {
12523 m_IsStoreLoad = value;
12524 }
12525
12526 override bool IsStoreLoad()
12527 {
12528 return m_IsStoreLoad;
12529 }
12530
12531 override void SetStoreLoadedQuantity(float value)
12532 {
12533 m_StoreLoadedQuantity = value;
12534 }
12535
12536 override float GetStoreLoadedQuantity()
12537 {
12538 return m_StoreLoadedQuantity;
12539 }
12540
12541 //----------------------------------------------------------------
12542
12543 float GetItemModelLength()
12544 {
12545 if (ConfigIsExisting("itemModelLength"))
12546 {
12547 return ConfigGetFloat("itemModelLength");
12548 }
12549 return 0;
12550 }
12551
12552 float GetItemAttachOffset()
12553 {
12554 if (ConfigIsExisting("itemAttachOffset"))
12555 {
12556 return ConfigGetFloat("itemAttachOffset");
12557 }
12558 return 0;
12559 }
12560
12561 override void SetCleanness(int value, bool allow_client = false)
12562 {
12563 if (!IsServerCheck(allow_client))
12564 return;
12565
12566 int previousValue = m_Cleanness;
12567
12568 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12569
12570 if (previousValue != m_Cleanness)
12571 SetVariableMask(VARIABLE_CLEANNESS);
12572 }
12573
12574 override int GetCleanness()
12575 {
12576 return m_Cleanness;
12577 }
12578
12580 {
12581 return true;
12582 }
12583
12584 //----------------------------------------------------------------
12585 // ATTACHMENT LOCKING
12586 // Getters relevant to generic ActionLockAttachment
12587 int GetLockType()
12588 {
12589 return m_LockType;
12590 }
12591
12592 string GetLockSoundSet()
12593 {
12594 return m_LockSoundSet;
12595 }
12596
12597 //----------------------------------------------------------------
12598 //------------------------- Color
12599 // sets items color variable given color components
12600 override void SetColor(int r, int g, int b, int a)
12601 {
12606 SetVariableMask(VARIABLE_COLOR);
12607 }
12609 override void GetColor(out int r,out int g,out int b,out int a)
12610 {
12615 }
12616
12617 bool IsColorSet()
12618 {
12619 return IsVariableSet(VARIABLE_COLOR);
12620 }
12621
12623 string GetColorString()
12624 {
12625 int r,g,b,a;
12626 GetColor(r,g,b,a);
12627 r = r/255;
12628 g = g/255;
12629 b = b/255;
12630 a = a/255;
12631 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12632 }
12633 //----------------------------------------------------------------
12634 //------------------------- LiquidType
12635
12636 override void SetLiquidType(int value, bool allow_client = false)
12637 {
12638 if (!IsServerCheck(allow_client))
12639 return;
12640
12641 int old = m_VarLiquidType;
12642 m_VarLiquidType = value;
12643 OnLiquidTypeChanged(old,value);
12644 SetVariableMask(VARIABLE_LIQUIDTYPE);
12645 }
12646
12647 int GetLiquidTypeInit()
12648 {
12649 return ConfigGetInt("varLiquidTypeInit");
12650 }
12651
12652 override int GetLiquidType()
12653 {
12654 return m_VarLiquidType;
12655 }
12656
12657 protected void OnLiquidTypeChanged(int oldType, int newType)
12658 {
12659 if (newType == LIQUID_NONE && GetIsFrozen())
12660 SetFrozen(false);
12661 }
12662
12664 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12665 {
12666 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12667 }
12668
12669 // -------------------------------------------------------------------------
12671 void OnInventoryEnter(Man player)
12672 {
12673 PlayerBase nplayer;
12674 if (PlayerBase.CastTo(nplayer, player))
12675 {
12676 m_CanPlayImpactSound = true;
12677 //nplayer.OnItemInventoryEnter(this);
12678 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12679 }
12680 }
12681
12682 // -------------------------------------------------------------------------
12684 void OnInventoryExit(Man player)
12685 {
12686 PlayerBase nplayer;
12687 if (PlayerBase.CastTo(nplayer,player))
12688 {
12689 //nplayer.OnItemInventoryExit(this);
12690 nplayer.SetEnableQuickBarEntityShortcut(this,false);
12691
12692 }
12693
12694 //if (!GetGame().IsDedicatedServer())
12695 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12696
12697
12698 if (HasEnergyManager())
12699 {
12700 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12701 }
12702 }
12703
12704 // ADVANCED PLACEMENT EVENTS
12705 override void OnPlacementStarted(Man player)
12706 {
12707 super.OnPlacementStarted(player);
12708
12709 SetTakeable(false);
12710 }
12711
12712 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12713 {
12714 if (m_AdminLog)
12715 {
12716 m_AdminLog.OnPlacementComplete(player, this);
12717 }
12718
12719 super.OnPlacementComplete(player, position, orientation);
12720 }
12721
12722 //-----------------------------
12723 // AGENT SYSTEM
12724 //-----------------------------
12725 //--------------------------------------------------------------------------
12726 bool ContainsAgent(int agent_id)
12727 {
12728 if (agent_id & m_AttachedAgents)
12729 {
12730 return true;
12731 }
12732 else
12733 {
12734 return false;
12735 }
12736 }
12737
12738 //--------------------------------------------------------------------------
12739 override void RemoveAgent(int agent_id)
12740 {
12741 if (ContainsAgent(agent_id))
12742 {
12743 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12744 }
12745 }
12746
12747 //--------------------------------------------------------------------------
12748 override void RemoveAllAgents()
12749 {
12750 m_AttachedAgents = 0;
12751 }
12752 //--------------------------------------------------------------------------
12753 override void RemoveAllAgentsExcept(int agent_to_keep)
12754 {
12755 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12756 }
12757 // -------------------------------------------------------------------------
12758 override void InsertAgent(int agent, float count = 1)
12759 {
12760 if (count < 1)
12761 return;
12762 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12764 }
12765
12767 void TransferAgents(int agents)
12768 {
12770 }
12771
12772 // -------------------------------------------------------------------------
12773 override int GetAgents()
12774 {
12775 return m_AttachedAgents;
12776 }
12777 //----------------------------------------------------------------------
12778
12779 /*int GetContaminationType()
12780 {
12781 int contamination_type;
12782
12783 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12784 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12785 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12786 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12787
12788 Edible_Base edible = Edible_Base.Cast(this);
12789 int agents = GetAgents();
12790 if (edible)
12791 {
12792 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12793 if (profile)
12794 {
12795 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12796 }
12797 }
12798 if (agents & CONTAMINATED_MASK)
12799 {
12800 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12801 }
12802 if (agents & POISONED_MASK)
12803 {
12804 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12805 }
12806 if (agents & NERVE_GAS_MASK)
12807 {
12808 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12809 }
12810 if (agents & DIRTY_MASK)
12811 {
12812 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12813 }
12814
12815 return agents;
12816 }*/
12817
12818 // -------------------------------------------------------------------------
12819 bool LoadAgents(ParamsReadContext ctx, int version)
12820 {
12821 if (!ctx.Read(m_AttachedAgents))
12822 return false;
12823 return true;
12824 }
12825 // -------------------------------------------------------------------------
12827 {
12828
12830 }
12831 // -------------------------------------------------------------------------
12832
12834 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12835 {
12836 super.CheckForRoofLimited(timeTresholdMS);
12837
12838 float time = GetGame().GetTime();
12839 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12840 {
12841 m_PreviousRoofTestTime = time;
12842 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12843 }
12844 }
12845
12846 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12847 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12848 {
12849 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12850 {
12851 return 0;
12852 }
12853
12854 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12855 {
12856 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12857 if (filter)
12858 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12859 else
12860 return 0;//otherwise return 0 when no filter attached
12861 }
12862
12863 string subclassPath, entryName;
12864
12865 switch (type)
12866 {
12867 case DEF_BIOLOGICAL:
12868 entryName = "biological";
12869 break;
12870 case DEF_CHEMICAL:
12871 entryName = "chemical";
12872 break;
12873 default:
12874 entryName = "biological";
12875 break;
12876 }
12877
12878 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12879
12880 return GetGame().ConfigGetFloat(subclassPath + entryName);
12881 }
12882
12883
12884
12886 override void EEOnCECreate()
12887 {
12888 if (!IsMagazine())
12890
12892 }
12893
12894
12895 //-------------------------
12896 // OPEN/CLOSE USER ACTIONS
12897 //-------------------------
12899 void Open();
12900 void Close();
12901 bool IsOpen()
12902 {
12903 return true;
12904 }
12905
12906 override bool CanDisplayCargo()
12907 {
12908 return IsOpen();
12909 }
12910
12911
12912 // ------------------------------------------------------------
12913 // CONDITIONS
12914 // ------------------------------------------------------------
12915 override bool CanPutInCargo(EntityAI parent)
12916 {
12917 if (parent)
12918 {
12919 if (parent.IsInherited(DayZInfected))
12920 return true;
12921
12922 if (!parent.IsRuined())
12923 return true;
12924 }
12925
12926 return true;
12927 }
12928
12929 override bool CanPutAsAttachment(EntityAI parent)
12930 {
12931 if (!super.CanPutAsAttachment(parent))
12932 {
12933 return false;
12934 }
12935
12936 if (!IsRuined() && !parent.IsRuined())
12937 {
12938 return true;
12939 }
12940
12941 return false;
12942 }
12943
12944 override bool CanReceiveItemIntoCargo(EntityAI item)
12945 {
12946 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12947 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12948 // return false;
12949
12950 return super.CanReceiveItemIntoCargo(item);
12951 }
12952
12953 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12954 {
12955 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12956 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12957 // return false;
12958
12959 GameInventory attachmentInv = attachment.GetInventory();
12960 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12961 {
12962 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12963 return false;
12964 }
12965
12966 InventoryLocation loc = new InventoryLocation();
12967 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12968 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12969 return false;
12970
12971 return super.CanReceiveAttachment(attachment, slotId);
12972 }
12973
12974 override bool CanReleaseAttachment(EntityAI attachment)
12975 {
12976 if (!super.CanReleaseAttachment(attachment))
12977 return false;
12978
12979 return GetInventory().AreChildrenAccessible();
12980 }
12981
12982 /*override bool CanLoadAttachment(EntityAI attachment)
12983 {
12984 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12985 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12986 // return false;
12987
12988 GameInventory attachmentInv = attachment.GetInventory();
12989 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12990 {
12991 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12992 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12993
12994 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12995 return false;
12996 }
12997
12998 return super.CanLoadAttachment(attachment);
12999 }*/
13000
13001 // Plays muzzle flash particle effects
13002 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13003 {
13004 int id = muzzle_owner.GetMuzzleID();
13005 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
13006
13007 if (WPOF_array)
13008 {
13009 for (int i = 0; i < WPOF_array.Count(); i++)
13010 {
13011 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
13012
13013 if (WPOF)
13014 {
13015 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
13016 }
13017 }
13018 }
13019 }
13020
13021 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
13022 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13023 {
13024 int id = muzzle_owner.GetMuzzleID();
13025 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
13026
13027 if (WPOBE_array)
13028 {
13029 for (int i = 0; i < WPOBE_array.Count(); i++)
13030 {
13031 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
13032
13033 if (WPOBE)
13034 {
13035 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13036 }
13037 }
13038 }
13039 }
13040
13041 // Plays all weapon overheating particles
13042 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13043 {
13044 int id = muzzle_owner.GetMuzzleID();
13045 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13046
13047 if (WPOOH_array)
13048 {
13049 for (int i = 0; i < WPOOH_array.Count(); i++)
13050 {
13051 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13052
13053 if (WPOOH)
13054 {
13055 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13056 }
13057 }
13058 }
13059 }
13060
13061 // Updates all weapon overheating particles
13062 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13063 {
13064 int id = muzzle_owner.GetMuzzleID();
13065 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13066
13067 if (WPOOH_array)
13068 {
13069 for (int i = 0; i < WPOOH_array.Count(); i++)
13070 {
13071 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13072
13073 if (WPOOH)
13074 {
13075 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13076 }
13077 }
13078 }
13079 }
13080
13081 // Stops overheating particles
13082 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13083 {
13084 int id = muzzle_owner.GetMuzzleID();
13085 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13086
13087 if (WPOOH_array)
13088 {
13089 for (int i = 0; i < WPOOH_array.Count(); i++)
13090 {
13091 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13092
13093 if (WPOOH)
13094 {
13095 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13096 }
13097 }
13098 }
13099 }
13100
13101 //----------------------------------------------------------------
13102 //Item Behaviour - unified approach
13103 override bool IsHeavyBehaviour()
13104 {
13105 if (m_ItemBehaviour == 0)
13106 {
13107 return true;
13108 }
13109
13110 return false;
13111 }
13112
13113 override bool IsOneHandedBehaviour()
13114 {
13115 if (m_ItemBehaviour == 1)
13116 {
13117 return true;
13118 }
13119
13120 return false;
13121 }
13122
13123 override bool IsTwoHandedBehaviour()
13124 {
13125 if (m_ItemBehaviour == 2)
13126 {
13127 return true;
13128 }
13129
13130 return false;
13131 }
13132
13133 bool IsDeployable()
13134 {
13135 return false;
13136 }
13137
13139 float GetDeployTime()
13140 {
13141 return UATimeSpent.DEFAULT_DEPLOY;
13142 }
13143
13144
13145 //----------------------------------------------------------------
13146 // Item Targeting (User Actions)
13147 override void SetTakeable(bool pState)
13148 {
13149 m_IsTakeable = pState;
13150 SetSynchDirty();
13151 }
13152
13153 override bool IsTakeable()
13154 {
13155 return m_IsTakeable;
13156 }
13157
13158 // For cases where we want to show object widget which cant be taken to hands
13160 {
13161 return false;
13162 }
13163
13165 protected void PreLoadSoundAttachmentType()
13166 {
13167 string att_type = "None";
13168
13169 if (ConfigIsExisting("soundAttType"))
13170 {
13171 att_type = ConfigGetString("soundAttType");
13172 }
13173
13174 m_SoundAttType = att_type;
13175 }
13176
13177 override string GetAttachmentSoundType()
13178 {
13179 return m_SoundAttType;
13180 }
13181
13182 //----------------------------------------------------------------
13183 //SOUNDS - ItemSoundHandler
13184 //----------------------------------------------------------------
13185
13186 string GetPlaceSoundset(); // played when deploy starts
13187 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13188 string GetDeploySoundset(); // played when deploy sucessfully finishes
13189 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13190 string GetFoldSoundset(); // played when fold sucessfully finishes
13191
13193 {
13194 if (!m_ItemSoundHandler)
13196
13197 return m_ItemSoundHandler;
13198 }
13199
13200 // override to initialize sounds
13201 protected void InitItemSounds()
13202 {
13203 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
13204 return;
13205
13207
13208 if (GetPlaceSoundset() != string.Empty)
13209 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13210
13211 if (GetDeploySoundset() != string.Empty)
13212 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13213
13214 SoundParameters params = new SoundParameters();
13215 params.m_Loop = true;
13216 if (GetLoopDeploySoundset() != string.Empty)
13217 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13218 }
13219
13220 // Start sound using ItemSoundHandler
13221 void StartItemSoundServer(int id)
13222 {
13223 if (!GetGame().IsServer())
13224 return;
13225
13226 m_SoundSyncPlay = id;
13227 SetSynchDirty();
13228
13229 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13231 }
13232
13233 // Stop sound using ItemSoundHandler
13234 void StopItemSoundServer(int id)
13235 {
13236 if (!GetGame().IsServer())
13237 return;
13238
13239 m_SoundSyncStop = id;
13240 SetSynchDirty();
13241
13242 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13244 }
13245
13246 protected void ClearStartItemSoundServer()
13247 {
13248 m_SoundSyncPlay = 0;
13249 }
13250
13251 protected void ClearStopItemSoundServer()
13252 {
13253 m_SoundSyncStop = 0;
13254 }
13255
13257 void PlayAttachSound(string slot_type)
13258 {
13259 if (!GetGame().IsDedicatedServer())
13260 {
13261 if (ConfigIsExisting("attachSoundSet"))
13262 {
13263 string cfg_path = "";
13264 string soundset = "";
13265 string type_name = GetType();
13266
13267 TStringArray cfg_soundset_array = new TStringArray;
13268 TStringArray cfg_slot_array = new TStringArray;
13269 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13270 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13271
13272 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13273 {
13274 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13275 {
13276 if (cfg_slot_array[i] == slot_type)
13277 {
13278 soundset = cfg_soundset_array[i];
13279 break;
13280 }
13281 }
13282 }
13283
13284 if (soundset != "")
13285 {
13286 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13287 sound.SetAutodestroy(true);
13288 }
13289 }
13290 }
13291 }
13292
13293 void PlayDetachSound(string slot_type)
13294 {
13295 //TODO - evaluate if needed and devise universal config structure if so
13296 }
13297
13298 void OnApply(PlayerBase player);
13299
13301 {
13302 return 1.0;
13303 };
13304 //returns applicable selection
13305 array<string> GetHeadHidingSelection()
13306 {
13308 }
13309
13311 {
13313 }
13314
13315 WrittenNoteData GetWrittenNoteData() {};
13316
13318 {
13319 SetDynamicPhysicsLifeTime(0.01);
13320 m_ItemBeingDroppedPhys = false;
13321 }
13322
13324 {
13325 array<string> zone_names = new array<string>;
13326 GetDamageZones(zone_names);
13327 for (int i = 0; i < zone_names.Count(); i++)
13328 {
13329 SetHealthMax(zone_names.Get(i),"Health");
13330 }
13331 SetHealthMax("","Health");
13332 }
13333
13335 void SetZoneDamageCEInit()
13336 {
13337 float global_health = GetHealth01("","Health");
13338 array<string> zones = new array<string>;
13339 GetDamageZones(zones);
13340 //set damage of all zones to match global health level
13341 for (int i = 0; i < zones.Count(); i++)
13342 {
13343 SetHealth01(zones.Get(i),"Health",global_health);
13344 }
13345 }
13346
13348 bool IsCoverFaceForShave(string slot_name)
13349 {
13350 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13351 }
13352
13353 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13354 {
13355 if (!hasRootAsPlayer)
13356 {
13357 if (refParentIB)
13358 {
13359 // parent is wet
13360 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13361 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13362 // parent has liquid inside
13363 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13364 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13365 // drying
13366 else if (m_VarWet > m_VarWetMin)
13367 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13368 }
13369 else
13370 {
13371 // drying on ground or inside non-itembase (car, ...)
13372 if (m_VarWet > m_VarWetMin)
13373 AddWet(-1 * delta * GetDryingIncrement("ground"));
13374 }
13375 }
13376 }
13377
13378 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13379 {
13381 {
13382 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13383 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13384 {
13385 float heatPermCoef = 1.0;
13386 EntityAI ent = this;
13387 while (ent)
13388 {
13389 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13390 ent = ent.GetHierarchyParent();
13391 }
13392
13393 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13394 }
13395 }
13396 }
13397
13398 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13399 {
13400 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13401 EntityAI parent = GetHierarchyParent();
13402 if (!parent)
13403 {
13404 hasParent = false;
13405 hasRootAsPlayer = false;
13406 }
13407 else
13408 {
13409 hasParent = true;
13410 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13411 refParentIB = ItemBase.Cast(parent);
13412 }
13413 }
13414
13415 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13416 {
13417 // this is stub, implemented on Edible_Base
13418 }
13419
13420 bool CanDecay()
13421 {
13422 // return true used on selected food clases so they can decay
13423 return false;
13424 }
13425
13426 protected bool CanProcessDecay()
13427 {
13428 // this is stub, implemented on Edible_Base class
13429 // used to determine whether it is still necessary for the food to decay
13430 return false;
13431 }
13432
13433 protected bool CanHaveWetness()
13434 {
13435 // return true used on selected items that have a wetness effect
13436 return false;
13437 }
13438
13440 bool CanBeConsumed(ConsumeConditionData data = null)
13441 {
13442 return !GetIsFrozen() && IsOpen();
13443 }
13444
13445 override void ProcessVariables()
13446 {
13447 bool hasParent = false, hasRootAsPlayer = false;
13448 ItemBase refParentIB;
13449
13450 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13451 bool foodDecay = g_Game.IsFoodDecayEnabled();
13452
13453 if (wwtu || foodDecay)
13454 {
13455 bool processWetness = wwtu && CanHaveWetness();
13456 bool processTemperature = wwtu && CanHaveTemperature();
13457 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13458
13459 if (processWetness || processTemperature || processDecay)
13460 {
13461 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13462
13463 if (processWetness)
13464 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13465
13466 if (processTemperature)
13467 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13468
13469 if (processDecay)
13470 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13471 }
13472 }
13473 }
13474
13477 {
13478 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13479 }
13480
13481 override float GetTemperatureFreezeThreshold()
13482 {
13484 return Liquid.GetFreezeThreshold(GetLiquidType());
13485
13486 return super.GetTemperatureFreezeThreshold();
13487 }
13488
13489 override float GetTemperatureThawThreshold()
13490 {
13492 return Liquid.GetThawThreshold(GetLiquidType());
13493
13494 return super.GetTemperatureThawThreshold();
13495 }
13496
13497 override float GetItemOverheatThreshold()
13498 {
13500 return Liquid.GetBoilThreshold(GetLiquidType());
13501
13502 return super.GetItemOverheatThreshold();
13503 }
13504
13505 override float GetTemperatureFreezeTime()
13506 {
13507 if (HasQuantity())
13508 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13509
13510 return super.GetTemperatureFreezeTime();
13511 }
13512
13513 override float GetTemperatureThawTime()
13514 {
13515 if (HasQuantity())
13516 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13517
13518 return super.GetTemperatureThawTime();
13519 }
13520
13522 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13524 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13525
13526 bool IsCargoException4x3(EntityAI item)
13527 {
13528 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13529 }
13530
13532 {
13533 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13534 }
13535
13537 void AddLightSourceItem(ItemBase lightsource)
13538 {
13539 m_LightSourceItem = lightsource;
13540 }
13541
13543 {
13544 m_LightSourceItem = null;
13545 }
13546
13548 {
13549 return m_LightSourceItem;
13550 }
13551
13553 array<int> GetValidFinishers()
13554 {
13555 return null;
13556 }
13557
13559 bool GetActionWidgetOverride(out typename name)
13560 {
13561 return false;
13562 }
13563
13564 bool PairWithDevice(notnull ItemBase otherDevice)
13565 {
13566 if (GetGame().IsServer())
13567 {
13568 ItemBase explosive = otherDevice;
13570 if (!trg)
13571 {
13572 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13573 explosive = this;
13574 }
13575
13576 explosive.PairRemote(trg);
13577 trg.SetControlledDevice(explosive);
13578
13579 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13580 trg.SetPersistentPairID(persistentID);
13581 explosive.SetPersistentPairID(persistentID);
13582
13583 return true;
13584 }
13585 return false;
13586 }
13587
13589 float GetBaitEffectivity()
13590 {
13591 float ret = 1.0;
13592 if (HasQuantity())
13593 ret *= GetQuantityNormalized();
13594 ret *= GetHealth01();
13595
13596 return ret;
13597 }
13598
13599 #ifdef DEVELOPER
13600 override void SetDebugItem()
13601 {
13602 super.SetDebugItem();
13603 _itemBase = this;
13604 }
13605
13606 override string GetDebugText()
13607 {
13608 string text = super.GetDebugText();
13609
13610 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13611 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13612
13613 return text;
13614 }
13615 #endif
13616
13617 bool CanBeUsedForSuicide()
13618 {
13619 return true;
13620 }
13621
13623 //DEPRECATED BELOW
13625 // Backwards compatibility
13626 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13627 {
13628 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13629 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13630 }
13631
13632 // replaced by ItemSoundHandler
13633 protected EffectSound m_SoundDeployFinish;
13634 protected EffectSound m_SoundPlace;
13635 protected EffectSound m_DeployLoopSoundEx;
13636 protected EffectSound m_SoundDeploy;
13637 bool m_IsPlaceSound;
13638 bool m_IsDeploySound;
13640
13641 string GetDeployFinishSoundset();
13642 void PlayDeploySound();
13643 void PlayDeployFinishSound();
13644 void PlayPlaceSound();
13645 void PlayDeployLoopSoundEx();
13646 void StopDeployLoopSoundEx();
13647 void SoundSynchRemoteReset();
13648 void SoundSynchRemote();
13649 bool UsesGlobalDeploy(){return false;}
13650 bool CanPlayDeployLoopSound(){return false;}
13652 bool IsPlaceSound(){return m_IsPlaceSound;}
13653 bool IsDeploySound(){return m_IsDeploySound;}
13654 void SetIsPlaceSound(bool is_place_sound);
13655 void SetIsDeploySound(bool is_deploy_sound);
13656}
13657
13658EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13659{
13660 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13661 if (entity)
13662 {
13663 bool is_item = entity.IsInherited(ItemBase);
13664 if (is_item && full_quantity)
13665 {
13666 ItemBase item = ItemBase.Cast(entity);
13667 item.SetQuantity(item.GetQuantityInit());
13668 }
13669 }
13670 else
13671 {
13672 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13673 return NULL;
13674 }
13675 return entity;
13676}
13677
13678void SetupSpawnedItem(ItemBase item, float health, float quantity)
13679{
13680 if (item)
13681 {
13682 if (health > 0)
13683 item.SetHealth("", "", health);
13684
13685 if (item.CanHaveTemperature())
13686 {
13687 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13688 if (item.CanFreeze())
13689 item.SetFrozen(false);
13690 }
13691
13692 if (item.HasEnergyManager())
13693 {
13694 if (quantity >= 0)
13695 {
13696 item.GetCompEM().SetEnergy0To1(quantity);
13697 }
13698 else
13699 {
13700 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13701 }
13702 }
13703 else if (item.IsMagazine())
13704 {
13705 Magazine mag = Magazine.Cast(item);
13706 if (quantity >= 0)
13707 {
13708 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13709 }
13710 else
13711 {
13712 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13713 }
13714
13715 }
13716 else
13717 {
13718 if (quantity >= 0)
13719 {
13720 item.SetQuantityNormalized(quantity, false);
13721 }
13722 else
13723 {
13724 item.SetQuantity(Math.AbsFloat(quantity));
13725 }
13726
13727 }
13728 }
13729}
13730
13731#ifdef DEVELOPER
13732ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13733#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения 3_Game/Entities/EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/Entities/EntityAI.c:2
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:14
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
int GetLiquidType()
Определения CCTWaterSurface.c:129
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:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:497
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:559
class GP5GasMask extends MaskBase ItemBase
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6380
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5620
bool HidesSelectionBySlot()
Определения ItemBase.c:9347
float m_VarWetMin
Определения ItemBase.c:4881
void SplitItem(PlayerBase player)
Определения ItemBase.c:6831
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9568
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8795
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:8229
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5625
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8938
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6798
override bool IsHeavyBehaviour()
Определения ItemBase.c:9140
override void SetWetMax()
Определения ItemBase.c:8511
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9385
void ClearStartItemSoundServer()
Определения ItemBase.c:9283
float m_VarWet
Определения ItemBase.c:4878
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9415
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8790
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4941
bool CanBeMovedOverride()
Определения ItemBase.c:7522
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8487
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4927
override void ProcessVariables()
Определения ItemBase.c:9482
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4955
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8321
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8856
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8701
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5211
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4953
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9518
bool m_IsSoundSynchRemote
Определения ItemBase.c:9676
float m_OverheatingShots
Определения ItemBase.c:4948
void StopItemSoundServer(int id)
Определения ItemBase.c:9271
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5640
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5364
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9542
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4965
bool CanBeCooked()
Определения ItemBase.c:7478
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5707
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4977
bool m_RecipesInitialized
Определения ItemBase.c:4863
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6471
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9526
override void OnEnergyConsumed()
Определения ItemBase.c:8431
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:8360
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8551
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8316
ref TIntArray m_InteractActions
Определения ItemBase.c:4929
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7542
float m_VarQuantity
Определения ItemBase.c:4869
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9687
override float GetWetMax()
Определения ItemBase.c:8521
bool CanBeUsedForSuicide()
Определения ItemBase.c:9654
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7117
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5845
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7696
void StartItemSoundServer(int id)
Определения ItemBase.c:9258
void DoAmmoExplosion()
Определения ItemBase.c:6315
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4940
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6655
int GetItemSize()
Определения ItemBase.c:7507
bool m_CanBeMovedOverride
Определения ItemBase.c:4906
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6239
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5432
bool CanDecay()
Определения ItemBase.c:9457
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:8202
void SetQuantityMax()
Определения ItemBase.c:8207
override float GetQuantity()
Определения ItemBase.c:8296
int m_ColorComponentR
Определения ItemBase.c:4918
int m_ShotsToStartOverheating
Определения ItemBase.c:4950
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8536
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5439
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9039
void OnOverheatingDecay()
Определения ItemBase.c:5402
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8469
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4884
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5540
bool UsesGlobalDeploy()
Определения ItemBase.c:9686
int m_ItemBehaviour
Определения ItemBase.c:4899
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9011
float m_HeatIsolation
Определения ItemBase.c:4894
float m_VarWetInit
Определения ItemBase.c:4880
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5885
void SetCEBasedQuantity()
Определения ItemBase.c:5653
bool m_CanPlayImpactSound
Определения ItemBase.c:4890
override string GetAttachmentSoundType()
Определения ItemBase.c:9214
float GetOverheatingCoef()
Определения ItemBase.c:5459
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9342
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9294
override bool IsStoreLoad()
Определения ItemBase.c:8563
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7093
bool IsLightSource()
Определения ItemBase.c:5781
bool m_HasQuantityBar
Определения ItemBase.c:4912
void SetResultOfSplit(bool value)
Определения ItemBase.c:7088
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6719
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6889
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5467
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8478
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9119
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8573
int m_LockType
Определения ItemBase.c:4966
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4971
bool m_CanBeDigged
Определения ItemBase.c:4913
float m_ItemAttachOffset
Определения ItemBase.c:4896
float GetItemModelLength()
Определения ItemBase.c:8580
bool m_ThrowItemOnDrop
Определения ItemBase.c:4904
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7841
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8871
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8464
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7122
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9513
bool CanHaveWetness()
Определения ItemBase.c:9470
int m_CleannessMin
Определения ItemBase.c:4886
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8804
string IDToName(int id)
Определения ItemBase.c:7689
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9477
float GetHeatIsolationInit()
Определения ItemBase.c:8459
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7529
override bool HasQuantity()
Определения ItemBase.c:8291
float m_VarWetPrev
Определения ItemBase.c:4879
int m_SoundSyncStop
Определения ItemBase.c:4973
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9563
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4928
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5549
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5234
int m_VarLiquidType
Определения ItemBase.c:4898
int m_QuickBarBonus
Определения ItemBase.c:4900
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9202
override float GetWetInit()
Определения ItemBase.c:8531
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4892
int m_SoundSyncPlay
Определения ItemBase.c:4972
int m_MaxOverheatingValue
Определения ItemBase.c:4951
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4875
bool m_IsTakeable
Определения ItemBase.c:4903
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6428
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4943
string GetLockSoundSet()
Определения ItemBase.c:8629
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8660
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9590
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6895
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4855
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9229
override int GetQuantityMin()
Определения ItemBase.c:8280
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6634
override int GetQuickBarBonus()
Определения ItemBase.c:5119
override void SetTakeable(bool pState)
Определения ItemBase.c:9184
float m_OverheatingDecayInterval
Определения ItemBase.c:4952
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6448
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9435
bool CanProcessDecay()
Определения ItemBase.c:9463
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5630
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9579
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7493
bool can_this_be_combined
Определения ItemBase.c:4908
EffectSound m_SoundDeploy
Определения ItemBase.c:9673
int m_Count
Определения ItemBase.c:4874
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9626
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9176
override bool IsSplitable()
Определения ItemBase.c:6415
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6399
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7805
void ConvertEnergyToQuantity()
Определения ItemBase.c:8446
override void RemoveAllAgents()
Определения ItemBase.c:8785
override void SetQuantityToMinimum()
Определения ItemBase.c:8213
bool m_WantPlayImpactSound
Определения ItemBase.c:4889
override float GetTemperatureThawTime()
Определения ItemBase.c:9550
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4942
int m_ColorComponentG
Определения ItemBase.c:4919
float m_StoreLoadedQuantity
Определения ItemBase.c:4876
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7560
int m_ColorComponentA
Определения ItemBase.c:4921
int m_VarQuantityInit
Определения ItemBase.c:4871
float GetFilterDamageRatio()
Определения ItemBase.c:5534
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8673
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6865
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:8220
bool m_HideSelectionsBySlot
Определения ItemBase.c:4956
bool IsOverheatingEffectActive()
Определения ItemBase.c:5397
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5814
int GetLiquidContainerMask()
Определения ItemBase.c:5751
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7002
ref Timer m_CheckOverheating
Определения ItemBase.c:4949
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:5445
float GetEnergy()
Определения ItemBase.c:8420
bool CanBeDigged()
Определения ItemBase.c:5830
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9596
bool IsNVG()
Определения ItemBase.c:5762
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8380
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9372
bool m_IsDeploySound
Определения ItemBase.c:9675
bool CanEat()
Определения ItemBase.c:7453
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9079
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9150
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9574
bool IsLiquidContainer()
Определения ItemBase.c:5746
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7473
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8307
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8863
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8261
int m_CleannessInit
Определения ItemBase.c:4885
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5529
override int GetAgents()
Определения ItemBase.c:8810
int m_VarQuantityMax
Определения ItemBase.c:4873
override bool IsHologram()
Определения ItemBase.c:5825
float GetItemAttachOffset()
Определения ItemBase.c:8589
bool IsPlaceSound()
Определения ItemBase.c:9689
static int GetDebugActionsMask()
Определения ItemBase.c:5615
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9452
override bool IsItemBase()
Определения ItemBase.c:7606
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9160
void ExplodeAmmo()
Определения ItemBase.c:6302
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7078
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8884
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9059
override void OnEnergyAdded()
Определения ItemBase.c:8438
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:5774
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9672
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7746
void StopItemDynamicPhysics()
Определения ItemBase.c:9354
bool HasFoodStage()
Определения ItemBase.c:7466
override void SetStoreLoad(bool value)
Определения ItemBase.c:8558
float GetOverheatingValue()
Определения ItemBase.c:5359
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8763
override void AddWet(float value)
Определения ItemBase.c:8506
bool IsLiquidPresent()
Определения ItemBase.c:5741
bool IsFullQuantity()
Определения ItemBase.c:8301
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6015
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6770
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6746
int m_CleannessMax
Определения ItemBase.c:4887
float m_VarStackMax
Определения ItemBase.c:4875
ref Timer m_PhysDropTimer
Определения ItemBase.c:4962
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7578
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8568
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4916
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5380
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5695
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7500
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8694
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5426
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8616
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4947
int m_LiquidContainerMask
Определения ItemBase.c:4897
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9390
override int GetCleanness()
Определения ItemBase.c:8611
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9601
bool IsDeploySound()
Определения ItemBase.c:9690
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5635
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9099
int m_VarQuantityMin
Определения ItemBase.c:4872
void PerformDamageSystemReinit()
Определения ItemBase.c:9360
override void ClearInventory()
Определения ItemBase.c:8399
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4944
ItemBase GetLightSourceItem()
Определения ItemBase.c:9584
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7596
override float GetItemOverheatThreshold()
Определения ItemBase.c:9534
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4909
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7710
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6685
float m_ItemModelLength
Определения ItemBase.c:4895
bool m_IsHologram
Определения ItemBase.c:4902
static int m_DebugActionsMask
Определения ItemBase.c:4862
void KillAllOverheatingParticles()
Определения ItemBase.c:5495
bool CanBeCookedOnStick()
Определения ItemBase.c:7483
override int GetQuantityMax()
Определения ItemBase.c:8248
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7156
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8654
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8776
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4905
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8966
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9330
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4856
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9663
override bool IsBeingPlaced()
Определения ItemBase.c:5809
int GetQuantityInit()
Определения ItemBase.c:8285
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7098
bool IsResultOfSplit()
Определения ItemBase.c:7083
bool m_FixDamageSystemInit
Определения ItemBase.c:4907
float m_ImpactSpeed
Определения ItemBase.c:4891
bool m_IsStoreLoad
Определения ItemBase.c:4910
int GetLiquidTypeInit()
Определения ItemBase.c:8684
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4925
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5682
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6557
int m_AttachedAgents
Определения ItemBase.c:4933
string m_LockSoundSet
Определения ItemBase.c:4968
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5303
float m_VarQuantityPrev
Определения ItemBase.c:4870
bool IsSoundSynchRemote()
Определения ItemBase.c:9688
bool m_CanShowQuantity
Определения ItemBase.c:4911
override void OnRightClick()
Определения ItemBase.c:6938
int m_ColorComponentB
Определения ItemBase.c:4920
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4858
bool IsActionTargetVisible()
Определения ItemBase.c:9196
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6050
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6339
bool m_IsBeingPlaced
Определения ItemBase.c:4901
int NameToID(string name)
Определения ItemBase.c:7683
void ~ItemBase()
Определения ItemBase.c:5580
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8546
void ClearStopItemSoundServer()
Определения ItemBase.c:9288
override string ChangeIntoOnDetach()
Определения ItemBase.c:6263
float m_VarWetMax
Определения ItemBase.c:4882
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6680
int GetLockType()
Определения ItemBase.c:8624
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9670
override float GetWet()
Определения ItemBase.c:8516
EffectSound m_SoundPlace
Определения ItemBase.c:9671
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8234
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8598
bool m_IsPlaceSound
Определения ItemBase.c:9674
override float GetWetMin()
Определения ItemBase.c:8526
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4974
override bool KindOf(string tag)
Определения ItemBase.c:7612
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:321
string GetDebugText()
Определения ModifierBase.c:71
PlayerBase GetPlayer()
Определения ModifierBase.c:51
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
EntityAI GetItem()
Определения RadialQuickbarMenu.c:37
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
void Debug()
Определения UniversalTemperatureSource.c:349
int GetID()
Определения ActionBase.c:1360
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:998
GetInputType()
Определения ActionBase.c:215
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
Определения AnalyticsManagerClient.c:77
proto native UIManager GetUIManager()
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native void GizmoSelectObject(Object object)
proto native bool ConfigIsExisting(string path)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native DayZPlayer GetPlayer()
proto native void GizmoSelectPhysics(Physics physics)
proto int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Global/game.c:1568
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local=false)
proto native void ObjectDelete(Object obj)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1280
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:541
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1275
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/Entities/Man.c:44
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
Определения ItemBase.c:15
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:469
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:29
override bool CanDisplayCargo()
Определения UndergroundStash.c:24
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
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 void SetActions()
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:412
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:424
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 IsClothing()
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
Определения 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 void Remove(func fn)
remove specific call from queue
proto void CallLater(func fn, int delay=0, bool repeat=false, 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)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
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:64
proto native float GetDamage(string zoneName, string healthType)
UIScriptedMenu FindMenu(int id)
Returns menu with specific ID if it is open (see MenuID)
Определения UIManager.c:160
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/tools/Debug.c:816
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:100
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
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/constants.c:512
const int DEF_CHEMICAL
Определения 3_Game/constants.c:513
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:709
array< int > TIntArray
Определения EnScript.c:711
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/constants.c:808
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/constants.c:632
const int VARIABLE_CLEANNESS
Определения 3_Game/constants.c:635
const int VARIABLE_COLOR
Определения 3_Game/constants.c:634
const int VARIABLE_TEMPERATURE
Определения 3_Game/constants.c:630
const int VARIABLE_QUANTITY
Определения 3_Game/constants.c:628
const int VARIABLE_WET
Определения 3_Game/constants.c:631
const int LIQUID_NONE
Определения 3_Game/constants.c:529
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/constants.c:453
const int SAT_DEBUG_ACTION
Определения 3_Game/constants.c:454
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
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/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/tools/tools.c:8
proto native int GetColor()