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

◆ SetTakeable()

override void SpawnItemOnLocation::SetTakeable ( bool pState)
protected

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

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

Используется в Barrel_ColorBase::Close(), FireplaceBase::Close(), Barrel_ColorBase::CloseLoad(), FireplaceBase::CloseLoad(), ImprovisedExplosive::EEHealthLevelChanged(), Plastic_Explosive::EEHealthLevelChanged(), EEItemAttached(), EEItemDetached(), LockServer(), Grenade_Base::OnActivateFinished(), Grenade_Base::OnActivateImmediate(), ImprovisedExplosive::OnDisarmed(), Plastic_Explosive::OnDisarmed(), ItemOptics::OnInventoryExit(), InventoryItem::OnPlacementStarted(), ItemOptics::OnWasAttached(), ItemOptics::OnWasDetached(), Barrel_ColorBase::Open(), FireplaceBase::Open(), Barrel_ColorBase::OpenLoad(), FireplaceBase::OpenLoad(), PlantBase(), ItemBase::SetMountedState() и UnlockServer().